js/src/jit-test/tests/basic/bug791465.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:da2cedbfc4ef
1 load(libdir + "asserts.js");
2
3 var valid_strict_funs = [
4 // directive ends on next line
5 function () {
6 "use strict"
7 ;
8 },
9 function () {
10 "use strict"
11 },
12 // directive ends on same line
13 function () { "use strict"; },
14 function () { "use strict" },
15 ];
16
17 for (var f of valid_strict_funs) {
18 assertThrowsInstanceOf(function() { f.caller }, TypeError);
19 }
20
21
22 var binary_ops = [
23 "||", "&&",
24 "|", "^", "&",
25 "==", "!=", "===", "!==",
26 "<", "<=", ">", ">=", "in", "instanceof",
27 "<<", ">>", ">>>",
28 "+", "-",
29 "*", "/", "%",
30 ];
31
32 var invalid_strict_funs = [
33 function () {
34 "use strict"
35 , "not";
36 },
37 function () {
38 "use strict"
39 ? 1 : 0;
40 },
41 function () {
42 "use strict"
43 .length;
44 },
45 function () {
46 "use strict"
47 [0];
48 },
49 function () {
50 "use strict"
51 ();
52 },
53 ...([]),
54 ...[Function("'use strict'\n " + op + " 'not'") for (op of binary_ops)],
55 ];
56
57 for (var f of invalid_strict_funs) {
58 f.caller;
59 }
60
61
62 var assignment_ops = [
63 "=", "+=", "-=",
64 "|=", "^=", "&=",
65 "<<=", ">>=", ">>>=",
66 "*=", "/=", "%=",
67 ];
68
69 var invalid_strict_funs_referror = [
70 ...[("'use strict'\n " + op + " 'not'") for (op of assignment_ops)],
71 ];
72
73 // assignment with string literal as LHS is an early error, therefore we
74 // can only test for ReferenceError
75 for (var f of invalid_strict_funs_referror) {
76 assertThrowsInstanceOf(function() { Function(f) }, ReferenceError);
77 }

mercurial