| 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 (should be the same code paths as test1 and test2). | 60 // Delete on an argument. This hits the same code paths as test5 because |
| 61 // 'with' forces all parameters to be indirected through the arguments |
| 62 // object. |
| 61 function test3(value) { | 63 function test3(value) { |
| 62 var status; | 64 var status; |
| 63 with ({}) { status = delete value; } | 65 with ({}) { status = delete value; } |
| 64 return value + ":" + status; | 66 return value + ":" + status; |
| 65 } | 67 } |
| 66 | 68 |
| 67 assertEquals("3:false", test3(3), "test3"); | 69 assertEquals("undefined:true", test3(3), "test3"); |
| 68 assertEquals(0, x, "test3"); // Global x is undisturbed. | 70 assertEquals(0, x, "test3"); // Global x is undisturbed. |
| 69 | 71 |
| 72 |
| 73 // Delete on an argument from an outer context. This hits the same code |
| 74 // path as test2. |
| 70 function test4(value) { | 75 function test4(value) { |
| 71 function f() { | 76 function f() { |
| 72 with ({}) { return delete value; } | 77 with ({}) { return delete value; } |
| 73 } | 78 } |
| 74 var status = f(); | 79 var status = f(); |
| 75 return value + ":" + status; | 80 return value + ":" + status; |
| 76 } | 81 } |
| 77 | 82 |
| 78 assertEquals("4:false", test4(4), "test4"); | 83 assertEquals("4:false", test4(4), "test4"); |
| 79 assertEquals(0, x, "test4"); // Global x is undisturbed. | 84 assertEquals(0, x, "test4"); // Global x is undisturbed. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 | 137 |
| 133 | 138 |
| 134 // Delete on a DONT_DELETE property of the global object. | 139 // Delete on a DONT_DELETE property of the global object. |
| 135 var y = 10; | 140 var y = 10; |
| 136 function test10() { | 141 function test10() { |
| 137 with ({}) { return delete y; } | 142 with ({}) { return delete y; } |
| 138 } | 143 } |
| 139 | 144 |
| 140 assertEquals(false, test10(), "test10"); | 145 assertEquals(false, test10(), "test10"); |
| 141 assertEquals(10, y, "test10"); | 146 assertEquals(10, y, "test10"); |
| OLD | NEW |