Skip to content

Rename assert_fault to assert_trap to match design repo terminology #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 22, 2015
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
2 changes: 1 addition & 1 deletion ml-proto/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ cmd:
<module> ;; define, validate, and initialize module
( invoke <name> <expr>* ) ;; invoke export and print result
( assert_eq (invoke <name> <expr>* ) <expr> ) ;; assert expected results of invocation
( assert_fault (invoke <name> <expr>* ) <failure> ) ;; assert invocation faults with given failure string
( assert_trap (invoke <name> <expr>* ) <failure> ) ;; assert invocation traps with given failure string
( assert_invalid <module> <failure> ) ;; assert invalid module with given failure string
```

Expand Down
2 changes: 1 addition & 1 deletion ml-proto/src/host/lexer.mll
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ rule token = parse

| "assert_invalid" { ASSERTINVALID }
| "assert_eq" { ASSERTEQ }
| "assert_fault" { ASSERTFAULT }
| "assert_trap" { ASSERTTRAP }
| "invoke" { INVOKE }

| name as s { VAR s }
Expand Down
6 changes: 3 additions & 3 deletions ml-proto/src/host/parser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ let anon_label c = {c with labels = VarMap.map ((+) 1) c.labels}
%token CONST UNARY BINARY COMPARE CONVERT
%token FUNC PARAM RESULT LOCAL MODULE MEMORY SEGMENT IMPORT EXPORT TABLE
%token PAGESIZE MEMORYSIZE RESIZEMEMORY
%token ASSERTINVALID ASSERTEQ ASSERTFAULT INVOKE
%token ASSERTINVALID ASSERTEQ ASSERTTRAP INVOKE
%token EOF

%token<string> INT
Expand Down Expand Up @@ -339,8 +339,8 @@ cmd :
{ Invoke ($3, $4 (c0 ())) @@ at() }
| LPAR ASSERTEQ LPAR INVOKE TEXT expr_list RPAR expr RPAR
{ AssertEq ($5, $6 (c0 ()), $8 (c0 ())) @@ at() }
| LPAR ASSERTFAULT LPAR INVOKE TEXT expr_list RPAR TEXT RPAR
{ AssertFault ($5, $6 (c0 ()), $8) @@ at() }
| LPAR ASSERTTRAP LPAR INVOKE TEXT expr_list RPAR TEXT RPAR
{ AssertTrap ($5, $6 (c0 ()), $8) @@ at() }
;
cmd_list :
| /* empty */ { [] }
Expand Down
10 changes: 5 additions & 5 deletions ml-proto/src/host/script.ml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ and command' =
| AssertInvalid of Ast.modul * string
| Invoke of string * Ast.expr list
| AssertEq of string * Ast.expr list * Ast.expr
| AssertFault of string * Ast.expr list * string
| AssertTrap of string * Ast.expr list * string

type script = command list

Expand Down Expand Up @@ -83,14 +83,14 @@ let run_command cmd =
Error.error cmd.at "assertion failed"
end

| AssertFault (name, es, re) ->
trace "Assert fault invoking...";
| AssertTrap (name, es, re) ->
trace "Assert trap invoking...";
let m = match !current_module with
| Some m -> m
| None -> Error.error cmd.at "no module defined to invoke"
in
let vs = eval_args es cmd.at in
assert_error (fun () -> Eval.invoke m name vs) "fault" re cmd.at
assert_error (fun () -> Eval.invoke m name vs) "trap" re cmd.at

let dry_command cmd =
match cmd.it with
Expand All @@ -100,7 +100,7 @@ let dry_command cmd =
| AssertInvalid _ -> ()
| Invoke _ -> ()
| AssertEq _ -> ()
| AssertFault _ -> ()
| AssertTrap _ -> ()

let run script =
List.iter (if !Flags.dry then dry_command else run_command) script
2 changes: 1 addition & 1 deletion ml-proto/src/host/script.mli
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ and command' =
| AssertInvalid of Ast.modul * string
| Invoke of string * Ast.expr list
| AssertEq of string * Ast.expr list * Ast.expr
| AssertFault of string * Ast.expr list * string
| AssertTrap of string * Ast.expr list * string

type script = command list

Expand Down
18 changes: 0 additions & 18 deletions ml-proto/test/memory_fault.wasm

This file was deleted.

18 changes: 18 additions & 0 deletions ml-proto/test/memory_trap.wasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
(module
(memory 100)

(export "store" $store)
(func $store (param $i i32) (param $v i32) (i32.store (get_local $i) (get_local $v)))

(export "load" $load)
(func $load (param $i i32) (result i32) (i32.load (get_local $i)))
)

(invoke "store" (i32.const 96) (i32.const 42))
(assert_eq (invoke "load" (i32.const 96)) (i32.const 42))
(assert_trap (invoke "store" (i32.const 97) (i32.const 13)) "runtime: out of bounds memory access")
(assert_trap (invoke "load" (i32.const 97)) "runtime: out of bounds memory access")
(assert_trap (invoke "store" (i32.const 98) (i32.const 13)) "runtime: out of bounds memory access")
(assert_trap (invoke "load" (i32.const 98)) "runtime: out of bounds memory access")
(assert_trap (invoke "store" (i32.const 99) (i32.const 13)) "runtime: out of bounds memory access")
(assert_trap (invoke "load" (i32.const 99)) "runtime: out of bounds memory access")
8 changes: 4 additions & 4 deletions ml-proto/test/resizing.wasm
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
(assert_eq (invoke "size") (i32.const 4096))
(invoke "store" (i32.const 0) (i32.const 42))
(assert_eq (invoke "load" (i32.const 0)) (i32.const 42))
(assert_fault (invoke "store" (i32.const 4096) (i32.const 42)) "runtime: out of bounds memory access")
(assert_fault (invoke "load" (i32.const 4096)) "runtime: out of bounds memory access")
(assert_trap (invoke "store" (i32.const 4096) (i32.const 42)) "runtime: out of bounds memory access")
(assert_trap (invoke "load" (i32.const 4096)) "runtime: out of bounds memory access")
(invoke "resize" (i32.const 8192))
(assert_eq (invoke "size") (i32.const 8192))
(assert_eq (invoke "load" (i32.const 0)) (i32.const 42))
Expand All @@ -28,5 +28,5 @@
(invoke "resize" (i32.const 4096))
(assert_eq (invoke "size") (i32.const 4096))
(assert_eq (invoke "load" (i32.const 0)) (i32.const 42))
(assert_fault (invoke "store" (i32.const 4096) (i32.const 42)) "runtime: out of bounds memory access")
(assert_fault (invoke "load" (i32.const 4096)) "runtime: out of bounds memory access")
(assert_trap (invoke "store" (i32.const 4096) (i32.const 42)) "runtime: out of bounds memory access")
(assert_trap (invoke "load" (i32.const 4096)) "runtime: out of bounds memory access")