Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: test/mjsunit/es6/unscopables.js

Issue 1045113002: ES6: Unscopable should use ToBoolean (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/contexts.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var global = this; 5 var global = this;
6 var globalProto = Object.getPrototypeOf(global); 6 var globalProto = Object.getPrototypeOf(global);
7 7
8 // Number of objects being tested. There is an assert ensuring this is correct. 8 // Number of objects being tested. There is an assert ensuring this is correct.
9 var objectCount = 21; 9 var objectCount = 21;
10 10
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 var z = 3; 123 var z = 3;
124 object.x = 4; 124 object.x = 4;
125 object.y = 5; 125 object.y = 5;
126 126
127 with (object) { 127 with (object) {
128 assertEquals(4, x); 128 assertEquals(4, x);
129 assertEquals(5, y); 129 assertEquals(5, y);
130 assertEquals(3, z); 130 assertEquals(3, z);
131 } 131 }
132 132
133 object[Symbol.unscopables] = {x: true}; 133 var truthyValues = [true, 1, 'x', {}, Symbol()];
134 with (object) { 134 for (var truthyValue of truthyValues) {
135 assertEquals(1, x); 135 object[Symbol.unscopables] = {x: truthyValue};
136 assertEquals(5, y); 136 with (object) {
137 assertEquals(3, z); 137 assertEquals(1, x);
138 assertEquals(5, y);
139 assertEquals(3, z);
140 }
138 } 141 }
139 142
140 object[Symbol.unscopables] = {x: 0, y: true}; 143 var falsyValues = [false, 0, -0, NaN, '', null, undefined];
141 with (object) { 144 for (var falsyValue of falsyValues) {
142 assertEquals(1, x); 145 object[Symbol.unscopables] = {x: falsyValue, y: true};
143 assertEquals(2, y); 146 with (object) {
144 assertEquals(3, z); 147 assertEquals(4, x);
148 assertEquals(2, y);
149 assertEquals(3, z);
150 }
145 } 151 }
146 152
147 object[Symbol.unscopables] = {x: 0, y: undefined}; 153 for (var xFalsy of falsyValues) {
148 with (object) { 154 for (var yFalsy of falsyValues) {
149 assertEquals(1, x); 155 object[Symbol.unscopables] = {x: xFalsy, y: yFalsy};
150 assertEquals(5, y); 156 with (object) {
151 assertEquals(3, z); 157 assertEquals(4, x);
158 assertEquals(5, y);
159 assertEquals(3, z);
160 }
161 }
152 } 162 }
153 } 163 }
154 runTest(TestBasics); 164 runTest(TestBasics);
155 165
156 166
157 function TestUnscopableChain(object) { 167 function TestUnscopableChain(object) {
158 var x = 1; 168 var x = 1;
159 object.x = 2; 169 object.x = 2;
160 170
161 with (object) { 171 with (object) {
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 throw new CustomError(); 724 throw new CustomError();
715 } 725 }
716 }; 726 };
717 assertThrows(function() { 727 assertThrows(function() {
718 with (object) { 728 with (object) {
719 x; 729 x;
720 } 730 }
721 }, CustomError); 731 }, CustomError);
722 } 732 }
723 TestGetUnscopablesGetterThrows(); 733 TestGetUnscopablesGetterThrows();
OLDNEW
« no previous file with comments | « src/contexts.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698