Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions custom/branch_hint.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
(module
(type (;0;) (func (param i32)))
(memory (;0;) 1 1)
(func $dummy)
(func $test1 (type 0)
(local i32)
local.get 1
local.get 0
i32.eq
(@metadata.code.branch_hint "\00" ) if
return
end
return
)
(func $test2 (type 0)
(local i32)
local.get 1
local.get 0
i32.eq
(@metadata.code.branch_hint "\01" ) if
return
end
return
)
(func (export "nested") (param i32 i32) (result i32)
(@metadata.code.branch_hint "\00")
(if (result i32) (local.get 0)
(then
(if (local.get 1) (then (call $dummy) (block) (nop)))
(if (local.get 1) (then) (else (call $dummy) (block) (nop)))
(@metadata.code.branch_hint "\01")
(if (result i32) (local.get 1)
(then (call $dummy) (i32.const 9))
(else (call $dummy) (i32.const 10))
)
)
(else
(if (local.get 1) (then (call $dummy) (block) (nop)))
(@metadata.code.branch_hint "\00")
(if (local.get 1) (then) (else (call $dummy) (block) (nop)))
(if (result i32) (local.get 1)
(then (call $dummy) (i32.const 10))
(else (call $dummy) (i32.const 11))
)
)
)
)
)

(assert_malformed_custom
(module quote
"(func $test2 (type 0)"
" (local i32)"
" local.get 1"
" local.get 0"
" i32.eq"
" (@metadata.code.branch_hint \"\\01\" )"
" (@metadata.code.branch_hint \"\\01\" )"
" if"
" return"
" end"
" return"
")"
)
"@metadata.code.branch_hint annotation: duplicate annotation"
)
(assert_malformed_custom
(module quote
"(module"
" (@metadata.code.branch_hint \"\\01\" )"
" (type (;0;) (func (param i32)))"
" (memory (;0;) 1 1)"
" (func $test (type 0)"
" (local i32)"
" local.get 1"
" local.get 0"
" i32.eq"
" return"
" )"
")"
)
"@metadata.code.branch_hint annotation: not in a function"
)

(assert_invalid_custom
(module
(type (;0;) (func (param i32)))
(memory (;0;) 1 1)
(func $test (type 0)
(local i32)
local.get 1
local.get 0
(@metadata.code.branch_hint "\01" )
i32.eq
return
)
)
"@metadata.code.branch_hint annotation: invalid target"
)
99 changes: 99 additions & 0 deletions custom/custom_annot.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
(module
(type $t (func))
(@custom "my-section1" "contents-bytes1")
(@custom "my-section2" "more-contents-bytes0")
(@custom "my-section1" "contents-bytes2")
(@custom "my-section2" (before global) "more-contents-bytes1")
(@custom "my-section2" (after func) "more-contents-bytes2")
(@custom "my-section2" (after func) "more-contents-bytes3")
(@custom "my-section2" (before global) "more-contents-bytes4")
(func)
(@custom "my-section2" "more-contents-bytes5")

(global $g i32 (i32.const 0))
(@custom "my-section3")
(@custom "my-section4" "" "1" "" "2" "3" "")
(@custom "")
)

(module quote "(@custom \"bla\")")
(module quote "(module (@custom \"bla\"))")


;; Malformed name

(assert_malformed_custom
(module quote "(@custom)")
"@custom annotation: missing section name"
)

(assert_malformed_custom
(module quote "(@custom 4)")
"@custom annotation: missing section name"
)

(assert_malformed_custom
(module quote "(@custom bla)")
"@custom annotation: missing section name"
)

(assert_malformed_custom
(module quote "(@custom \"\\df\")")
"@custom annotation: malformed UTF-8 encoding"
)


;; Malformed placement

(assert_malformed_custom
(module quote "(@custom \"bla\" here)")
"@custom annotation: unexpected token"
)

(assert_malformed_custom
(module quote "(@custom \"bla\" after)")
"@custom annotation: unexpected token"
)

(assert_malformed_custom
(module quote "(@custom \"bla\" (after))")
"@custom annotation: malformed section kind"
)

(assert_malformed_custom
(module quote "(@custom \"bla\" (type))")
"@custom annotation: malformed placement"
)

(assert_malformed_custom
(module quote "(@custom \"bla\" (aft type))")
"@custom annotation: malformed placement"
)

(assert_malformed_custom
(module quote "(@custom \"bla\" (before types))")
"@custom annotation: malformed section kind"
)


;; Misplaced

(assert_malformed_custom
(module quote "(type (@custom \"bla\") $t (func))")
"misplaced @custom annotation"
)

(assert_malformed_custom
(module quote "(func (@custom \"bla\"))")
"misplaced @custom annotation"
)

(assert_malformed_custom
(module quote "(func (block (@custom \"bla\")))")
"misplaced @custom annotation"
)

(assert_malformed_custom
(module quote "(func (nop (@custom \"bla\")))")
"misplaced @custom annotation"
)
38 changes: 38 additions & 0 deletions custom/name_annot.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
;; Module names

(module (@name "Modül"))

(module $moduel (@name "Modül"))

(assert_malformed_custom
(module quote "(module (@name \"M1\") (@name \"M2\"))")
"@name annotation: multiple module"
)

(assert_malformed_custom
(module quote "(module (func) (@name \"M\"))")
"misplaced @name annotation"
)

(assert_malformed_custom
(module quote "(module (start $f (@name \"M\")) (func $f))")
"misplaced @name annotation"
)


;; Function names

(module
(type $t (func))
(func (@name "λ") (type $t))
(func $lambda (@name "λ") (type $t))
)


;; Tag names

(module
(type $t (func))
(tag (@name "θ") (type $t))
(tag $theta (@name "θ") (type $t))
)
7 changes: 4 additions & 3 deletions update-testsuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def list_tests(self):
This is used to run diffs and copy the test to its final location.
"""
tests = []
for subdir in ['core', 'legacy']:
for subdir in ['core', 'legacy', 'custom']:
for root, dirs, files in os.walk(f'repos/test/{subdir}'):
for file in files:
path = os.path.join(root, file)
Expand All @@ -127,8 +127,8 @@ def list_tests(self):
if ext != '.wast':
continue
dst = os.path.basename(path)
if subdir == 'legacy':
dst = 'legacy/' + dst
if subdir in ['legacy', 'custom']:
dst = subdir + '/' + dst
tests.append((path, repo_path, dst))
return tests

Expand Down Expand Up @@ -157,6 +157,7 @@ def main():
spec.checkout_merge()
tests = []
for path, _repo_path, dst in spec.list_tests():
os.makedirs(os.path.dirname(dst) or '.', exist_ok=True)
shutil.copyfile(path, dst)
tests.append(dst)
git('add', *tests, quiet=True)
Expand Down