blob: a0f3c432f74b51eaf67f953baaf838e0236862b5 [file] [log] [blame]
Ben Murdochc5610432016-08-08 18:44:38 +01001// 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
3// found in the LICENSE file.
4
5// Flags: --expose-wasm
6
7var __v_5 = {};
8var __v_35 = {};
9var __v_44 = {};
10var __v_43 = {};
11
12try {
13__v_1 = 1;
14__v_2 = {
15 get: function() { return function() {} },
16 has() { return true },
17 getOwnPropertyDescriptor: function() {
18 if (__v_1-- == 0) throw "please die";
19 return {value: function() {}, configurable: true};
20 }
21};
22__v_3 = new Proxy({}, __v_2);
23__v_30 = Object.create(__v_35);
24with (__v_5) { f() }
25} catch(e) { print("Caught: " + e); }
26
27function __f_1(asmfunc, expect) {
28 var __v_1 = asmfunc.toString();
29 var __v_2 = __v_1.replace(new RegExp("use asm"), "");
30 var __v_39 = {Math: Math};
31 var __v_4 = eval("(" + __v_2 + ")")(__v_3);
32 print("Testing " + asmfunc.name + " (js)...");
33 __v_44.valueOf = __v_43;
34 expect(__v_4);
35 print("Testing " + asmfunc.name + " (asm.js)...");
36 var __v_5 = asmfunc(__v_3);
37 expect(__v_5);
38 print("Testing " + asmfunc.name + " (wasm)...");
39 var __v_6 = Wasm.instantiateModuleFromAsm(__v_1, __v_3);
40 expect(__v_6);
41}
42function __f_2() {
43 "use asm";
44 function __f_3() { return 0; }
45 function __f_4() { return 1; }
46 function __f_5() { return 4; }
47 function __f_6() { return 64; }
48 function __f_7() { return 137; }
49 function __f_8() { return 128; }
50 function __f_9() { return -1; }
51 function __f_10() { return 1000; }
52 function __f_11() { return 2000000; }
53 function __f_12() { return 2147483647; }
54 return {__f_3: __f_3, __f_4: __f_4, __f_5: __f_5, __f_6: __f_6, __f_7: __f_7, __f_8: __f_8,
55 __f_9: __f_9, __f_10: __f_10, __f_11, __f_12: __f_12};
56}
57try {
58__f_1(__f_2, function(module) {
59 assertEquals(0, module.__f_3());
60 assertEquals(1, module.__f_4());
61 assertEquals(4, module.__f_5());
62 assertEquals(64, module.__f_6());
63 assertEquals(128, module.__f_8());
64 assertEquals(-1, module.__f_9());
65 assertEquals(1000, module.__f_10());
66 assertEquals(2000000, module.__f_11());
67 assertEquals(2147483647, module.__f_12());
68});
69} catch(e) { print("Caught: " + e); }