OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Flags: --expose-wasm | 5 // Flags: --expose-wasm |
6 | 6 |
7 load("test/mjsunit/wasm/wasm-constants.js"); | 7 load("test/mjsunit/wasm/wasm-constants.js"); |
8 load("test/mjsunit/wasm/wasm-module-builder.js"); | 8 load("test/mjsunit/wasm/wasm-module-builder.js"); |
9 | 9 |
10 function toByteArray(s) { | 10 function toByteArray(s) { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 ffi[imported_module_name][imported_function_name] = function() { }; | 72 ffi[imported_module_name][imported_function_name] = function() { }; |
73 } | 73 } |
74 | 74 |
75 var hasThrown = true; | 75 var hasThrown = true; |
76 try { | 76 try { |
77 builder.instantiate(ffi); | 77 builder.instantiate(ffi); |
78 hasThrown = false; | 78 hasThrown = false; |
79 } catch (err) { | 79 } catch (err) { |
80 if (!shouldThrow) print(err); | 80 if (!shouldThrow) print(err); |
81 assertTrue(shouldThrow, "Should not throw error on valid names"); | 81 assertTrue(shouldThrow, "Should not throw error on valid names"); |
| 82 assertTrue(err instanceof Error, "exception should be an Error"); |
82 assertContains("UTF-8", err.toString()); | 83 assertContains("UTF-8", err.toString()); |
83 } | 84 } |
84 assertEquals(shouldThrow, hasThrown, | 85 assertEquals(shouldThrow, hasThrown, |
85 "Should throw validation error on invalid names"); | 86 "Should throw validation error on invalid names"); |
86 } | 87 } |
87 | 88 |
88 function checkImportedModuleName(name, shouldThrow) { | 89 function checkImportedModuleName(name, shouldThrow) { |
89 checkImportsAndExports(name, "imp", "func", undefined, shouldThrow); | 90 checkImportsAndExports(name, "imp", "func", undefined, shouldThrow); |
90 } | 91 } |
91 | 92 |
(...skipping 20 matching lines...) Expand all Loading... |
112 checkAll("some math: (½)² = ¼", false); | 113 checkAll("some math: (½)² = ¼", false); |
113 checkAll("中国历史系列条目\n北", false); | 114 checkAll("中国历史系列条目\n北", false); |
114 checkAll(toByteArray("\xef\xb7\x8f"), false); | 115 checkAll(toByteArray("\xef\xb7\x8f"), false); |
115 checkAll(toByteArray("a\xc2\x81\xe1\x80\xbf\xf1\x80\xa0\xbf"), false); | 116 checkAll(toByteArray("a\xc2\x81\xe1\x80\xbf\xf1\x80\xa0\xbf"), false); |
116 checkAll(toByteArray("\xff"), true); | 117 checkAll(toByteArray("\xff"), true); |
117 checkAll(toByteArray("\xed\xa0\x8f"), true); // surrogate code points | 118 checkAll(toByteArray("\xed\xa0\x8f"), true); // surrogate code points |
118 checkAll(toByteArray("\xe0\x82\x80"), true); // overlong sequence | 119 checkAll(toByteArray("\xe0\x82\x80"), true); // overlong sequence |
119 checkAll(toByteArray("\xf4\x90\x80\x80"), true); // beyond limit: U+110000 | 120 checkAll(toByteArray("\xf4\x90\x80\x80"), true); // beyond limit: U+110000 |
120 checkAll(toByteArray("\xef\xbf\xbe"), true); // non-character; U+FFFE | 121 checkAll(toByteArray("\xef\xbf\xbe"), true); // non-character; U+FFFE |
121 checkAll(toByteArray("with\x00null"), false); | 122 checkAll(toByteArray("with\x00null"), false); |
OLD | NEW |