Reviewers: adamk,
Message:
PTAL
Description:
ES6: Unscopable should use ToBoolean
The spec settled on ToBoolean instead of only using not undefined.
BUG=v8:3827
LOG=N
R=adamk
Please review this at https://codereview.chromium.org/1045113002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+26, -16 lines):
M src/contexts.cc
M test/mjsunit/es6/unscopables.js
Index: src/contexts.cc
diff --git a/src/contexts.cc b/src/contexts.cc
index
6bd6764546702d8cf2a9de42b55435e3046b6e9f..a6a61df624a49c9460806a96fee5b166ba65efcd
100644
--- a/src/contexts.cc
+++ b/src/contexts.cc
@@ -141,7 +141,7 @@ static Maybe<PropertyAttributes>
UnscopableLookup(LookupIterator* it) {
DCHECK(isolate->has_pending_exception());
return Nothing<PropertyAttributes>();
}
- return blacklist->IsUndefined() ? attrs : Just(ABSENT);
+ return blacklist->BooleanValue() ? Just(ABSENT) : attrs;
}
static void GetAttributesAndBindingFlags(VariableMode mode,
Index: test/mjsunit/es6/unscopables.js
diff --git a/test/mjsunit/es6/unscopables.js
b/test/mjsunit/es6/unscopables.js
index
03612bec533a6c51a0ffd6340ec08ef295d28e12..782dd2d7a36d800029c367cc78d8bc4c1396207d
100644
--- a/test/mjsunit/es6/unscopables.js
+++ b/test/mjsunit/es6/unscopables.js
@@ -130,25 +130,35 @@ function TestBasics(object) {
assertEquals(3, z);
}
- object[Symbol.unscopables] = {x: true};
- with (object) {
- assertEquals(1, x);
- assertEquals(5, y);
- assertEquals(3, z);
+ var truthyValues = [true, 1, 'x', {}, Symbol()];
+ for (var truthyValue of truthyValues) {
+ object[Symbol.unscopables] = {x: truthyValue};
+ with (object) {
+ assertEquals(1, x);
+ assertEquals(5, y);
+ assertEquals(3, z);
+ }
}
- object[Symbol.unscopables] = {x: 0, y: true};
- with (object) {
- assertEquals(1, x);
- assertEquals(2, y);
- assertEquals(3, z);
+ var falsyValues = [false, 0, -0, NaN, '', null, undefined];
+ for (var falsyValue of falsyValues) {
+ object[Symbol.unscopables] = {x: falsyValue, y: true};
+ with (object) {
+ assertEquals(4, x);
+ assertEquals(2, y);
+ assertEquals(3, z);
+ }
}
- object[Symbol.unscopables] = {x: 0, y: undefined};
- with (object) {
- assertEquals(1, x);
- assertEquals(5, y);
- assertEquals(3, z);
+ for (var xFalsy of falsyValues) {
+ for (var yFalsy of falsyValues) {
+ object[Symbol.unscopables] = {x: xFalsy, y: yFalsy};
+ with (object) {
+ assertEquals(4, x);
+ assertEquals(5, y);
+ assertEquals(3, z);
+ }
+ }
}
}
runTest(TestBasics);
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.