summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-02-22 10:18:48 -0800
committerGitHub <noreply@github.com>2024-02-22 10:18:48 -0800
commit4969f936bd44943b08525aff3db709dfc24ab1d6 (patch)
tree4fdc4d46b88b36fe6e05a22a56efad2fabfce5f4 /test
parentf6bb943490dc87b16481bfc1604a796edf2acea8 (diff)
downloadbinaryen-4969f936bd44943b08525aff3db709dfc24ab1d6.tar.gz
binaryen-4969f936bd44943b08525aff3db709dfc24ab1d6.tar.bz2
binaryen-4969f936bd44943b08525aff3db709dfc24ab1d6.zip
Fuzzer: Match the logging of i31ref between JS and C++ (#6335)
JS engines print i31ref as just a number, so we need a small regex to standardize the representation (similar to what we do for funcrefs on the code above). On the C++ side, make it actually print the i31ref rather than treat it like a generic reference (for whom we only print "object"). To do that we must unwrap an externalized i31 as necessary, and add a case for i31 in the printing logic. Also move that printing logic to its own function, as it was starting to get quite long.
Diffstat (limited to 'test')
-rw-r--r--test/lit/exec/i31.wast29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/lit/exec/i31.wast b/test/lit/exec/i31.wast
index 70d220d8c..0833d490d 100644
--- a/test/lit/exec/i31.wast
+++ b/test/lit/exec/i31.wast
@@ -76,6 +76,27 @@
(ref.null i31)
)
)
+
+ ;; CHECK: [fuzz-exec] calling return-i31
+ ;; CHECK-NEXT: [fuzz-exec] note result: return-i31 => i31ref(42)
+ (func $return-i31 (export "return-i31") (result i31ref)
+ ;; An i31 should be logged out using its integer value, unlike a struct or
+ ;; array which ends up as only "object".
+ (ref.i31
+ (i32.const 42)
+ )
+ )
+
+ ;; CHECK: [fuzz-exec] calling return-exted-i31
+ ;; CHECK-NEXT: [fuzz-exec] note result: return-exted-i31 => i31ref(42)
+ (func $return-exted-i31 (export "return-exted-i31") (result externref)
+ ;; Even an externalized i31 is logged out using its integer value.
+ (extern.externalize
+ (ref.i31
+ (i32.const 42)
+ )
+ )
+ )
)
;; CHECK: [fuzz-exec] calling null-local
;; CHECK-NEXT: [fuzz-exec] note result: null-local => 1
@@ -97,10 +118,18 @@
;; CHECK: [fuzz-exec] calling trap
;; CHECK-NEXT: [trap null ref]
+
+;; CHECK: [fuzz-exec] calling return-i31
+;; CHECK-NEXT: [fuzz-exec] note result: return-i31 => i31ref(42)
+
+;; CHECK: [fuzz-exec] calling return-exted-i31
+;; CHECK-NEXT: [fuzz-exec] note result: return-exted-i31 => i31ref(42)
;; CHECK-NEXT: [fuzz-exec] comparing nn-s
;; CHECK-NEXT: [fuzz-exec] comparing nn-u
;; CHECK-NEXT: [fuzz-exec] comparing non-null
;; CHECK-NEXT: [fuzz-exec] comparing null-immediate
;; CHECK-NEXT: [fuzz-exec] comparing null-local
+;; CHECK-NEXT: [fuzz-exec] comparing return-exted-i31
+;; CHECK-NEXT: [fuzz-exec] comparing return-i31
;; CHECK-NEXT: [fuzz-exec] comparing trap
;; CHECK-NEXT: [fuzz-exec] comparing zero-is-not-null