diff options
-rwxr-xr-x | auto_update_tests.py | 9 | ||||
-rwxr-xr-x | check.py | 11 | ||||
-rw-r--r-- | src/wasm-s-parser.h | 2 | ||||
-rw-r--r-- | test/print/min.minified.txt | 54 | ||||
-rw-r--r-- | test/print/min.minified.wast | 1 |
5 files changed, 76 insertions, 1 deletions
diff --git a/auto_update_tests.py b/auto_update_tests.py index 86c4ebbeb..939d8d278 100755 --- a/auto_update_tests.py +++ b/auto_update_tests.py @@ -44,6 +44,15 @@ for wasm in ['address.wast']:#os.listdir(os.path.join('test', 'spec')): expected_file = os.path.join('test', asm) open(expected_file, 'w').write(actual) +for t in sorted(os.listdir(os.path.join('test', 'print'))): + if t.endswith('.wast'): + print '..', t + wasm = os.path.basename(t).replace('.wast', '') + cmd = [os.path.join('bin', 'binaryen-shell'), os.path.join('test', 'print', t), '--print'] + print ' ', ' '.join(cmd) + actual, err = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() + open(os.path.join('test', 'print', wasm + '.txt'), 'w').write(actual) + for t in sorted(os.listdir(os.path.join('test', 'passes'))): if t.endswith('.wast'): print '..', t @@ -279,6 +279,17 @@ for asm in tests: raise Exception('wasm interpreter error: ' + err) # failed to pretty-print raise Exception('wasm interpreter error') +print '\n[ checking binaryen-shell parsing & printing... ]\n' + +for t in sorted(os.listdir(os.path.join('test', 'print'))): + if t.endswith('.wast'): + print '..', t + name = os.path.basename(t).replace('.wast', '') + cmd = [os.path.join('bin', 'binaryen-shell'), os.path.join('test', 'print', t), '--print'] + print ' ', ' '.join(cmd) + actual, err = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() + fail_if_not_identical(actual, open(os.path.join('test', 'print', name + '.txt')).read()) + print '\n[ checking binaryen-shell passes... ]\n' for t in sorted(os.listdir(os.path.join('test', 'passes'))): diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h index cf900ce28..a6b8e61b6 100644 --- a/src/wasm-s-parser.h +++ b/src/wasm-s-parser.h @@ -205,7 +205,7 @@ private: input++; return allocator.alloc<Element>()->setString(IString(str.c_str(), false), dollared); } - while (input[0] && !isspace(input[0]) && input[0] != ')') input++; + while (input[0] && !isspace(input[0]) && input[0] != ')' && input[0] != '(') input++; char temp = input[0]; input[0] = 0; auto ret = allocator.alloc<Element>()->setString(IString(start, false), dollared); // TODO: reuse the string here, carefully diff --git a/test/print/min.minified.txt b/test/print/min.minified.txt new file mode 100644 index 000000000..b66f98c30 --- /dev/null +++ b/test/print/min.minified.txt @@ -0,0 +1,54 @@ +(module + (memory 16777216 16777216) + (export "floats" $floats) + (func $floats (param $f f32) (result f32) + (local $t f32) + (f32.add + (get_local $t) + (get_local $f) + ) + ) + (func $neg (param $k i32) (param $p i32) + (local $n f32) + (set_local $n + (f32.neg + (block $block0 + (i32.store + (get_local $k) + (get_local $p) + ) + (f32.load + (get_local $k) + ) + ) + ) + ) + ) + (func $littleswitch (param $x i32) (result i32) + (block $topmost + (tableswitch $switch$0 + (i32.sub + (get_local $x) + (i32.const 1) + ) + (table (case $switch-case$1) (case $switch-case$2)) (case $switch-case$1) + (case $switch-case$1 + (br $topmost + (i32.const 1) + ) + ) + (case $switch-case$2 + (br $topmost + (i32.const 2) + ) + ) + ) + (i32.const 0) + ) + ) + (func $f1 (param $i1 i32) (param $i2 i32) (param $i3 i32) (result i32) + (block $topmost + (get_local $i3) + ) + ) +) diff --git a/test/print/min.minified.wast b/test/print/min.minified.wast new file mode 100644 index 000000000..35ea01ace --- /dev/null +++ b/test/print/min.minified.wast @@ -0,0 +1 @@ +(module(memory 16777216 16777216)(export "floats" $floats)(func $floats(param $f f32)(result f32)(local $t f32)(f32.add(get_local $t)(get_local $f)))(func $neg(param $k i32)(param $p i32)(local $n f32)(set_local $n(f32.neg(block $block0(i32.store(get_local $k)(get_local $p))(f32.load(get_local $k))))))(func $littleswitch(param $x i32)(result i32)(block $topmost(tableswitch $switch$0(i32.sub(get_local $x)(i32.const 1))(table(case $switch-case$1)(case $switch-case$2)) (case $switch-case$1)(case $switch-case$1(br $topmost(i32.const 1)))(case $switch-case$2(br $topmost(i32.const 2))))(i32.const 0)))(func $f1(param $i1 i32)(param $i2 i32)(param $i3 i32)(result i32)(block $topmost(get_local $i3)))) |