OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 24 matching lines...) Expand all Loading... |
35 // Verify the code compiles just fine in non-strict mode | 35 // Verify the code compiles just fine in non-strict mode |
36 // (using aliased eval to force non-strict mode) | 36 // (using aliased eval to force non-strict mode) |
37 var eval_alias = eval; | 37 var eval_alias = eval; |
38 | 38 |
39 eval_alias(code1); | 39 eval_alias(code1); |
40 eval_alias(code2); | 40 eval_alias(code2); |
41 eval_alias(code3); | 41 eval_alias(code3); |
42 eval_alias(code4); | 42 eval_alias(code4); |
43 | 43 |
44 function strict1() { | 44 function strict1() { |
| 45 var exception = false; |
45 try { | 46 try { |
46 eval(code1); | 47 eval(code1); |
47 assertUnreachable("did not throw exception"); | |
48 } catch (e) { | 48 } catch (e) { |
| 49 exception = true; |
49 assertInstanceof(e, SyntaxError); | 50 assertInstanceof(e, SyntaxError); |
50 } | 51 } |
| 52 assertTrue(exception); |
51 | 53 |
52 function strict2() { | 54 function strict2() { |
| 55 var exception = false; |
53 try { | 56 try { |
54 eval(code2); | 57 eval(code2); |
55 assertUnreachable("did not throw exception"); | |
56 } catch (e) { | 58 } catch (e) { |
| 59 exception = true; |
57 assertInstanceof(e, SyntaxError); | 60 assertInstanceof(e, SyntaxError); |
58 } | 61 } |
| 62 assertTrue(exception); |
59 | 63 |
60 function strict3() { | 64 function strict3() { |
| 65 var exception = false; |
61 try { | 66 try { |
62 eval(code3); | 67 eval(code3); |
63 assertUnreachable("did not throw exception"); | |
64 } catch (e) { | 68 } catch (e) { |
| 69 exception = true; |
65 assertInstanceof(e, SyntaxError); | 70 assertInstanceof(e, SyntaxError); |
66 } | 71 } |
| 72 assertTrue(exception); |
67 | 73 |
68 function strict4() { | 74 function strict4() { |
| 75 var exception = false; |
69 try { | 76 try { |
70 eval(code4); | 77 eval(code4); |
71 assertUnreachable("did not throw exception"); | |
72 } catch (e) { | 78 } catch (e) { |
| 79 exception = true; |
73 assertInstanceof(e, SyntaxError); | 80 assertInstanceof(e, SyntaxError); |
74 } | 81 } |
| 82 assertTrue(exception); |
75 } | 83 } |
76 strict4(); | 84 strict4(); |
77 } | 85 } |
78 strict3(); | 86 strict3(); |
79 } | 87 } |
80 strict2(); | 88 strict2(); |
81 } | 89 } |
82 strict1(); | 90 strict1(); |
OLD | NEW |