| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 } | 50 } |
| 51 var value = 2; | 51 var value = 2; |
| 52 var status = f(); | 52 var status = f(); |
| 53 return value + ":" + status; | 53 return value + ":" + status; |
| 54 } | 54 } |
| 55 | 55 |
| 56 assertEquals("2:false", test2(), "test2"); | 56 assertEquals("2:false", test2(), "test2"); |
| 57 assertEquals(0, x, "test2"); // Global x is undisturbed. | 57 assertEquals(0, x, "test2"); // Global x is undisturbed. |
| 58 | 58 |
| 59 | 59 |
| 60 // Delete on an argument. This hits the same code paths as test5 because | 60 // Delete on a parameter. |
| 61 // 'with' forces all parameters to be indirected through the arguments | |
| 62 // object. | |
| 63 function test3(value) { | 61 function test3(value) { |
| 64 var status; | 62 var status; |
| 65 with ({}) { status = delete value; } | 63 with ({}) { status = delete value; } |
| 66 return value + ":" + status; | 64 return value + ":" + status; |
| 67 } | 65 } |
| 68 | 66 |
| 69 assertEquals("undefined:true", test3(3), "test3"); | 67 assertEquals("3:false", test3(3), "test3"); |
| 70 assertEquals(0, x, "test3"); // Global x is undisturbed. | 68 assertEquals(0, x, "test3"); // Global x is undisturbed. |
| 71 | 69 |
| 72 | 70 |
| 73 // Delete on an argument from an outer context. This hits the same code | 71 // Delete on a parameter found in an outer context. |
| 74 // path as test2. | |
| 75 function test4(value) { | 72 function test4(value) { |
| 76 function f() { | 73 function f() { |
| 77 with ({}) { return delete value; } | 74 with ({}) { return delete value; } |
| 78 } | 75 } |
| 79 var status = f(); | 76 var status = f(); |
| 80 return value + ":" + status; | 77 return value + ":" + status; |
| 81 } | 78 } |
| 82 | 79 |
| 83 assertEquals("4:false", test4(4), "test4"); | 80 assertEquals("4:false", test4(4), "test4"); |
| 84 assertEquals(0, x, "test4"); // Global x is undisturbed. | 81 assertEquals(0, x, "test4"); // Global x is undisturbed. |
| 85 | 82 |
| 86 | 83 |
| 87 // Delete on an argument found in the arguments object. Such properties are | 84 // Delete on a parameter, arguments object should be unaffected. |
| 88 // normally DONT_DELETE in JavaScript but deletion is allowed by V8. | |
| 89 function test5(value) { | 85 function test5(value) { |
| 90 var status; | 86 var status; |
| 91 with ({}) { status = delete value; } | 87 with ({}) { status = delete value; } |
| 92 return arguments[0] + ":" + status; | 88 return arguments[0] + ":" + status; |
| 93 } | 89 } |
| 94 | 90 |
| 95 assertEquals("undefined:true", test5(5), "test5"); | 91 assertEquals("5:false", test5(5), "test5"); |
| 96 assertEquals(0, x, "test5"); // Global x is undisturbed. | 92 assertEquals(0, x, "test5"); // Global x is undisturbed. |
| 97 | 93 |
| 98 function test6(value) { | 94 function test6(value) { |
| 99 function f() { | 95 function f() { |
| 100 with ({}) { return delete value; } | 96 with ({}) { return delete value; } |
| 101 } | 97 } |
| 102 var status = f(); | 98 var status = f(); |
| 103 return arguments[0] + ":" + status; | 99 return arguments[0] + ":" + status; |
| 104 } | 100 } |
| 105 | 101 |
| 106 assertEquals("undefined:true", test6(6), "test6"); | 102 assertEquals("6:false", test6(6), "test6"); |
| 107 assertEquals(0, x, "test6"); // Global x is undisturbed. | 103 assertEquals(0, x, "test6"); // Global x is undisturbed. |
| 108 | 104 |
| 109 | 105 |
| 110 // Delete on a property found on 'with' object. | 106 // Delete on a property found on 'with' object. |
| 111 function test7(object) { | 107 function test7(object) { |
| 112 with (object) { return delete value; } | 108 with (object) { return delete value; } |
| 113 } | 109 } |
| 114 | 110 |
| 115 var o = {value: 7}; | 111 var o = {value: 7}; |
| 116 assertEquals(true, test7(o), "test7"); | 112 assertEquals(true, test7(o), "test7"); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 137 | 133 |
| 138 | 134 |
| 139 // Delete on a DONT_DELETE property of the global object. | 135 // Delete on a DONT_DELETE property of the global object. |
| 140 var y = 10; | 136 var y = 10; |
| 141 function test10() { | 137 function test10() { |
| 142 with ({}) { return delete y; } | 138 with ({}) { return delete y; } |
| 143 } | 139 } |
| 144 | 140 |
| 145 assertEquals(false, test10(), "test10"); | 141 assertEquals(false, test10(), "test10"); |
| 146 assertEquals(10, y, "test10"); | 142 assertEquals(10, y, "test10"); |
| OLD | NEW |