Skip to content

Commit eedf8b3

Browse files
authored
Fix json-from-wast where assert_return contains const values (#2435)
* Fix json-from-wast where assert_return contains const values * fix format
1 parent a92516b commit eedf8b3

4 files changed

Lines changed: 50 additions & 1 deletion

File tree

crates/json-from-wast/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ where
560560
}
561561

562562
#[derive(Serialize, Deserialize, Debug)]
563-
#[serde(tag = "type", rename_all = "lowercase")]
563+
#[serde(tag = "type", content = "value", rename_all = "lowercase")]
564564
pub enum ComponentConst<'a> {
565565
#[serde(borrow)]
566566
String(Cow<'a, str>),
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
;; RUN: wast --assert default --snapshot tests/snapshots %
2+
3+
(component
4+
(core module $m (func (export "") (result i32) i32.const 1))
5+
(core instance $m (instantiate $m))
6+
(func (export "a") (result u32) (canon lift (core func $m "")))
7+
)
8+
9+
(assert_return (invoke "a") (u32.const 1))
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"source_filename": "tests/cli/component-model/assert_return.wast",
3+
"commands": [
4+
{
5+
"type": "module",
6+
"line": 3,
7+
"filename": "assert_return.0.wasm",
8+
"module_type": "binary"
9+
},
10+
{
11+
"type": "assert_return",
12+
"line": 9,
13+
"action": {
14+
"type": "invoke",
15+
"field": "a",
16+
"args": []
17+
},
18+
"expected": [
19+
{
20+
"type": "u32",
21+
"value": "1"
22+
}
23+
]
24+
}
25+
]
26+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
(component
2+
(core module $m (;0;)
3+
(type (;0;) (func (result i32)))
4+
(export "" (func 0))
5+
(func (;0;) (type 0) (result i32)
6+
i32.const 1
7+
)
8+
)
9+
(core instance $m (;0;) (instantiate $m))
10+
(type (;0;) (func (result u32)))
11+
(alias core export $m "" (core func (;0;)))
12+
(func (;0;) (type 0) (canon lift (core func 0)))
13+
(export (;1;) "a" (func 0))
14+
)

0 commit comments

Comments
 (0)