built-ins/Proxy/*: make all indentation consistent (depth & character) (#1434)

This commit is contained in:
Rick Waldron 2018-02-15 15:11:36 -05:00 committed by Leo Balter
parent 133dfa8793
commit 4fd36e7f1d
184 changed files with 847 additions and 761 deletions

View File

@ -12,7 +12,9 @@ info: |
---*/ ---*/
var _target, _args, _handler, _context; var _target, _args, _handler, _context;
var target = function(a, b) { return a + b; }; var target = function(a, b) {
return a + b;
};
var handler = { var handler = {
apply: function(t, c, args) { apply: function(t, c, args) {
_handler = this; _handler = this;

View File

@ -10,7 +10,9 @@ info: |
9. Return Call(trap, handler, «target, thisArgument, argArray»). 9. Return Call(trap, handler, «target, thisArgument, argArray»).
---*/ ---*/
var target = function(a, b) { return a + b; }; var target = function(a, b) {
return a + b;
};
var result = {}; var result = {};
var handler = { var handler = {
apply: function(t, c, args) { apply: function(t, c, args) {

View File

@ -6,7 +6,9 @@ description: >
Return is an abrupt completion Return is an abrupt completion
---*/ ---*/
var target = function(a, b) { return a + b; }; var target = function(a, b) {
return a + b;
};
var p = new Proxy(target, { var p = new Proxy(target, {
apply: function(t, c, args) { apply: function(t, c, args) {
throw new Test262Error(); throw new Test262Error();

View File

@ -31,7 +31,9 @@ function target(a, b) {
} }
var ctx = {}; var ctx = {};
var p = new Proxy(target, {apply: null}); var p = new Proxy(target, {
apply: null
});
var res = p.call(ctx, 1, 2); var res = p.call(ctx, 1, 2);
assert.sameValue(res, 3, "`apply` trap is `null`"); assert.sameValue(res, 3, "`apply` trap is `null`");
assert.sameValue(calls, 1, "target is called once"); assert.sameValue(calls, 1, "target is called once");

View File

@ -31,7 +31,9 @@ function target(a, b) {
} }
var ctx = {}; var ctx = {};
var p = new Proxy(target, {apply: undefined}); var p = new Proxy(target, {
apply: undefined
});
var res = p.call(ctx, 1, 2); var res = p.call(ctx, 1, 2);
assert.sameValue(res, 3, "`apply` trap is `null`"); assert.sameValue(res, 3, "`apply` trap is `null`");
assert.sameValue(calls, 1, "target is called once"); assert.sameValue(calls, 1, "target is called once");

View File

@ -15,6 +15,7 @@ features: [Reflect.construct]
---*/ ---*/
function Target() {} function Target() {}
function NewTarget() {} function NewTarget() {}
var handler = { var handler = {
@ -29,7 +30,9 @@ var handler = {
assert.sameValue(b, 2, "arguments list has second construct argument"); assert.sameValue(b, 2, "arguments list has second construct argument");
assert.sameValue(newTarget, NewTarget, "newTarget is passed as the third parameter"); assert.sameValue(newTarget, NewTarget, "newTarget is passed as the third parameter");
return {sum: a + b}; return {
sum: a + b
};
}, },
}; };

View File

@ -13,6 +13,7 @@ info: |
---*/ ---*/
var _target, _handler, _args, _P; var _target, _handler, _args, _P;
function Target() {} function Target() {}
var handler = { var handler = {

View File

@ -15,7 +15,9 @@ function Target(a, b) {
}; };
var handler = { var handler = {
construct: function(t, c, args) { construct: function(t, c, args) {
return { sum: 42 }; return {
sum: 42
};
} }
}; };
var P = new Proxy(Target, handler); var P = new Proxy(Target, handler);

View File

@ -27,13 +27,18 @@ features: [Reflect.construct]
var calls = 0; var calls = 0;
function NewTarget() {} function NewTarget() {}
function Target(a, b) { function Target(a, b) {
assert.sameValue(new.target, NewTarget); assert.sameValue(new.target, NewTarget);
calls += 1; calls += 1;
return {sum: a + b}; return {
sum: a + b
};
} }
var P = new Proxy(Target, {construct: null}); var P = new Proxy(Target, {
construct: null
});
var obj = Reflect.construct(P, [3, 4], NewTarget); var obj = Reflect.construct(P, [3, 4], NewTarget);
assert.sameValue(obj.sum, 7, "`construct` trap is `null`"); assert.sameValue(obj.sum, 7, "`construct` trap is `null`");
assert.sameValue(calls, 1, "target is called once"); assert.sameValue(calls, 1, "target is called once");

View File

@ -16,10 +16,13 @@ features: [Reflect.construct]
var calls = 0; var calls = 0;
function NewTarget() {} function NewTarget() {}
function Target(a, b) { function Target(a, b) {
assert.sameValue(new.target, NewTarget); assert.sameValue(new.target, NewTarget);
calls += 1; calls += 1;
return {sum: a + b}; return {
sum: a + b
};
} }
var P = new Proxy(Target, {}); var P = new Proxy(Target, {});

View File

@ -27,13 +27,18 @@ features: [Reflect.construct]
var calls = 0; var calls = 0;
function NewTarget() {} function NewTarget() {}
function Target(a, b) { function Target(a, b) {
assert.sameValue(new.target, NewTarget); assert.sameValue(new.target, NewTarget);
calls += 1; calls += 1;
return {sum: a + b}; return {
sum: a + b
};
} }
var P = new Proxy(Target, {construct: undefined}); var P = new Proxy(Target, {
construct: undefined
});
var obj = Reflect.construct(P, [3, 4], NewTarget); var obj = Reflect.construct(P, [3, 4], NewTarget);
assert.sameValue(obj.sum, 7, "`construct` trap is `undefined`"); assert.sameValue(obj.sum, 7, "`construct` trap is `undefined`");
assert.sameValue(calls, 1, "target is called once"); assert.sameValue(calls, 1, "target is called once");

View File

@ -22,6 +22,8 @@ features: [cross-realm]
var other = $262.createRealm().global; var other = $262.createRealm().global;
var C = new other.Function(); var C = new other.Function();
// Ensure that the proxy does not report a `prototype` property // Ensure that the proxy does not report a `prototype` property
var P = new Proxy(C, { get: function() {} }); var P = new Proxy(C, {
get: function() {}
});
assert.sameValue(Object.getPrototypeOf(new P()), other.Object.prototype); assert.sameValue(Object.getPrototypeOf(new P()), other.Object.prototype);

View File

@ -18,7 +18,9 @@ var target = {
} }
}; };
var p = new Proxy(target, { get: null }); var p = new Proxy(target, {
get: null
});
assert.sameValue(p.attr, p); assert.sameValue(p.attr, p);
var pParent = Object.create(new Proxy(target, {})); var pParent = Object.create(new Proxy(target, {}));

View File

@ -13,7 +13,9 @@ info: |
---*/ ---*/
var _target, _handler, _prop; var _target, _handler, _prop;
var target = {attr: 1}; var target = {
attr: 1
};
var handler = { var handler = {
getOwnPropertyDescriptor: function(t, prop) { getOwnPropertyDescriptor: function(t, prop) {
_target = t; _target = t;

View File

@ -16,7 +16,9 @@ features: [cross-realm]
var OProxy = $262.createRealm().global.Proxy; var OProxy = $262.createRealm().global.Proxy;
var p = new OProxy({}, { var p = new OProxy({}, {
getOwnPropertyDescriptor: function() { return null; } getOwnPropertyDescriptor: function() {
return null;
}
}); });
assert.throws(TypeError, function() { assert.throws(TypeError, function() {

View File

@ -18,7 +18,9 @@ var target = {};
var p = new Proxy(target, { var p = new Proxy(target, {
getOwnPropertyDescriptor: function(t, prop) { getOwnPropertyDescriptor: function(t, prop) {
var foo = { bar: 1 }; var foo = {
bar: 1
};
return Object.getOwnPropertyDescriptor(foo, "bar"); return Object.getOwnPropertyDescriptor(foo, "bar");
} }

View File

@ -14,7 +14,9 @@ info: |
includes: [propertyHelper.js] includes: [propertyHelper.js]
---*/ ---*/
var target = {attr: 1}; var target = {
attr: 1
};
var p = new Proxy(target, {}); var p = new Proxy(target, {});
var proxyDesc = Object.getOwnPropertyDescriptor(p, "attr"); var proxyDesc = Object.getOwnPropertyDescriptor(p, "attr");

View File

@ -22,7 +22,9 @@ info: |
---*/ ---*/
var prot = { foo: 1 }; var prot = {
foo: 1
};
var p = new Proxy({}, { var p = new Proxy({}, {
getPrototypeOf: function() { getPrototypeOf: function() {
return prot; return prot;

View File

@ -25,7 +25,9 @@ info: |
... ...
---*/ ---*/
var target = Object.create({ foo: 1 }); var target = Object.create({
foo: 1
});
var p = new Proxy(target, { var p = new Proxy(target, {
getPrototypeOf: function() { getPrototypeOf: function() {

View File

@ -13,7 +13,9 @@ info: |
a. Return trapResult. a. Return trapResult.
---*/ ---*/
var p = new Proxy({attr: 42}, { var p = new Proxy({
attr: 42
}, {
ownKeys: function() { ownKeys: function() {
return ["foo", "bar"]; return ["foo", "bar"];
} }

View File

@ -25,7 +25,9 @@ info: |
var p = new Proxy({}, { var p = new Proxy({}, {
ownKeys() { ownKeys() {
return [[]]; return [
[]
];
} }
}); });

View File

@ -19,7 +19,9 @@ features: [cross-realm]
---*/ ---*/
var OProxy = $262.createRealm().global.Proxy; var OProxy = $262.createRealm().global.Proxy;
var p = new OProxy({attr:1}, { var p = new OProxy({
attr: 1
}, {
ownKeys: {} ownKeys: {}
}); });

View File

@ -16,7 +16,9 @@ info: |
4. If IsCallable(func) is false, throw a TypeError exception. 4. If IsCallable(func) is false, throw a TypeError exception.
---*/ ---*/
var p = new Proxy({attr:1}, { var p = new Proxy({
attr: 1
}, {
ownKeys: {} ownKeys: {}
}); });

View File

@ -16,4 +16,3 @@ description: >
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Proxy({}, {}); Proxy({}, {});
}); });

View File

@ -14,4 +14,6 @@ info: |
var revocationFunction = Proxy.revocable({}, {}).revoke; var revocationFunction = Proxy.revocable({}, {}).revoke;
assert.sameValue(Object.prototype.hasOwnProperty.call(revocationFunction, "prototype"), false); assert.sameValue(Object.prototype.hasOwnProperty.call(revocationFunction, "prototype"), false);
assert.throws(TypeError, function() { new revocationFunction(); }); assert.throws(TypeError, function() {
new revocationFunction();
});

View File

@ -19,7 +19,9 @@ var target = {
} }
}; };
var p = new Proxy(target, { set: null }); var p = new Proxy(target, {
set: null
});
p.attr = 1; p.attr = 1;
assert.sameValue(context, p); assert.sameValue(context, p);

View File

@ -15,7 +15,9 @@ info: |
var _handler, _target, _value; var _handler, _target, _value;
var target = {}; var target = {};
var val = {foo: 1}; var val = {
foo: 1
};
var handler = { var handler = {
setPrototypeOf: function(t, v) { setPrototypeOf: function(t, v) {
_handler = this; _handler = this;

View File

@ -18,5 +18,7 @@ var p = new Proxy({}, {
}); });
assert.throws(Test262Error, function() { assert.throws(Test262Error, function() {
Object.setPrototypeOf(p, {value: 1}); Object.setPrototypeOf(p, {
value: 1
});
}); });

View File

@ -32,30 +32,44 @@ var p = new Proxy(target, {
var result; var result;
result = Reflect.setPrototypeOf(p, { attr: false }); result = Reflect.setPrototypeOf(p, {
attr: false
});
assert.sameValue(result, false, "false"); assert.sameValue(result, false, "false");
assert.sameValue(called, 0, "false - isExtensible is not called"); assert.sameValue(called, 0, "false - isExtensible is not called");
result = Reflect.setPrototypeOf(p, { attr: "" }); result = Reflect.setPrototypeOf(p, {
attr: ""
});
assert.sameValue(result, false, "the empty string"); assert.sameValue(result, false, "the empty string");
assert.sameValue(called, 0, "the empty string - isExtensible is not called"); assert.sameValue(called, 0, "the empty string - isExtensible is not called");
result = Reflect.setPrototypeOf(p, { attr: 0 }); result = Reflect.setPrototypeOf(p, {
attr: 0
});
assert.sameValue(result, false, "0"); assert.sameValue(result, false, "0");
assert.sameValue(called, 0, "0 - isExtensible is not called"); assert.sameValue(called, 0, "0 - isExtensible is not called");
result = Reflect.setPrototypeOf(p, { attr: -0 }); result = Reflect.setPrototypeOf(p, {
attr: -0
});
assert.sameValue(result, false, "-0"); assert.sameValue(result, false, "-0");
assert.sameValue(called, 0, "-0 - isExtensible is not called"); assert.sameValue(called, 0, "-0 - isExtensible is not called");
result = Reflect.setPrototypeOf(p, { attr: null }); result = Reflect.setPrototypeOf(p, {
attr: null
});
assert.sameValue(result, false, "null"); assert.sameValue(result, false, "null");
assert.sameValue(called, 0, "null - isExtensible is not called"); assert.sameValue(called, 0, "null - isExtensible is not called");
result = Reflect.setPrototypeOf(p, { attr: undefined }); result = Reflect.setPrototypeOf(p, {
attr: undefined
});
assert.sameValue(result, false, "undefined"); assert.sameValue(result, false, "undefined");
assert.sameValue(called, 0, "undefined - isExtensible is not called"); assert.sameValue(called, 0, "undefined - isExtensible is not called");
result = Reflect.setPrototypeOf(p, { attr: NaN }); result = Reflect.setPrototypeOf(p, {
attr: NaN
});
assert.sameValue(result, false, "NaN"); assert.sameValue(result, false, "NaN");
assert.sameValue(called, 0, "NaN - isExtensible is not called"); assert.sameValue(called, 0, "NaN - isExtensible is not called");

View File

@ -36,31 +36,43 @@ var p = new Proxy(target, {
var result; var result;
called = 0; called = 0;
result = Reflect.setPrototypeOf(p, { attr: true }); result = Reflect.setPrototypeOf(p, {
attr: true
});
assert.sameValue(result, true, "true"); assert.sameValue(result, true, "true");
assert.sameValue(called, 1, "true - isExtensible is called"); assert.sameValue(called, 1, "true - isExtensible is called");
called = 0; called = 0;
result = Reflect.setPrototypeOf(p, { attr: "false" }); result = Reflect.setPrototypeOf(p, {
attr: "false"
});
assert.sameValue(result, true, "string"); assert.sameValue(result, true, "string");
assert.sameValue(called, 1, "string - isExtensible is called"); assert.sameValue(called, 1, "string - isExtensible is called");
called = 0; called = 0;
result = Reflect.setPrototypeOf(p, { attr: 42 }); result = Reflect.setPrototypeOf(p, {
attr: 42
});
assert.sameValue(result, true, "42"); assert.sameValue(result, true, "42");
assert.sameValue(called, 1, "number - isExtensible is called"); assert.sameValue(called, 1, "number - isExtensible is called");
called = 0; called = 0;
result = Reflect.setPrototypeOf(p, { attr: p }); result = Reflect.setPrototypeOf(p, {
attr: p
});
assert.sameValue(result, true, "p"); assert.sameValue(result, true, "p");
assert.sameValue(called, 1, "object - isExtensible is called"); assert.sameValue(called, 1, "object - isExtensible is called");
called = 0; called = 0;
result = Reflect.setPrototypeOf(p, { attr: [] }); result = Reflect.setPrototypeOf(p, {
attr: []
});
assert.sameValue(result, true, "[]"); assert.sameValue(result, true, "[]");
assert.sameValue(called, 1, "[] - isExtensible is called"); assert.sameValue(called, 1, "[] - isExtensible is called");
called = 0; called = 0;
result = Reflect.setPrototypeOf(p, { attr: Symbol(1) }); result = Reflect.setPrototypeOf(p, {
attr: Symbol(1)
});
assert.sameValue(result, true, "symbol"); assert.sameValue(result, true, "symbol");
assert.sameValue(called, 1, "symbol - isExtensible is called"); assert.sameValue(called, 1, "symbol - isExtensible is called");