mirror of
https://github.com/tc39/test262.git
synced 2025-07-27 07:54:41 +02:00
built-ins/Proxy/*: make all indentation consistent (depth & character) (#1434)
This commit is contained in:
parent
133dfa8793
commit
4fd36e7f1d
@ -12,7 +12,9 @@ info: |
|
||||
---*/
|
||||
|
||||
var _target, _args, _handler, _context;
|
||||
var target = function(a, b) { return a + b; };
|
||||
var target = function(a, b) {
|
||||
return a + b;
|
||||
};
|
||||
var handler = {
|
||||
apply: function(t, c, args) {
|
||||
_handler = this;
|
||||
|
@ -10,7 +10,9 @@ info: |
|
||||
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 handler = {
|
||||
apply: function(t, c, args) {
|
||||
|
@ -6,7 +6,9 @@ description: >
|
||||
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, {
|
||||
apply: function(t, c, args) {
|
||||
throw new Test262Error();
|
||||
|
@ -31,7 +31,9 @@ function target(a, b) {
|
||||
}
|
||||
|
||||
var ctx = {};
|
||||
var p = new Proxy(target, {apply: null});
|
||||
var p = new Proxy(target, {
|
||||
apply: null
|
||||
});
|
||||
var res = p.call(ctx, 1, 2);
|
||||
assert.sameValue(res, 3, "`apply` trap is `null`");
|
||||
assert.sameValue(calls, 1, "target is called once");
|
||||
|
@ -31,7 +31,9 @@ function target(a, b) {
|
||||
}
|
||||
|
||||
var ctx = {};
|
||||
var p = new Proxy(target, {apply: undefined});
|
||||
var p = new Proxy(target, {
|
||||
apply: undefined
|
||||
});
|
||||
var res = p.call(ctx, 1, 2);
|
||||
assert.sameValue(res, 3, "`apply` trap is `null`");
|
||||
assert.sameValue(calls, 1, "target is called once");
|
||||
|
@ -15,6 +15,7 @@ features: [Reflect.construct]
|
||||
---*/
|
||||
|
||||
function Target() {}
|
||||
|
||||
function NewTarget() {}
|
||||
|
||||
var handler = {
|
||||
@ -29,7 +30,9 @@ var handler = {
|
||||
assert.sameValue(b, 2, "arguments list has second construct argument");
|
||||
assert.sameValue(newTarget, NewTarget, "newTarget is passed as the third parameter");
|
||||
|
||||
return {sum: a + b};
|
||||
return {
|
||||
sum: a + b
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -13,6 +13,7 @@ info: |
|
||||
---*/
|
||||
|
||||
var _target, _handler, _args, _P;
|
||||
|
||||
function Target() {}
|
||||
|
||||
var handler = {
|
||||
|
@ -15,7 +15,9 @@ function Target(a, b) {
|
||||
};
|
||||
var handler = {
|
||||
construct: function(t, c, args) {
|
||||
return { sum: 42 };
|
||||
return {
|
||||
sum: 42
|
||||
};
|
||||
}
|
||||
};
|
||||
var P = new Proxy(Target, handler);
|
||||
|
@ -27,13 +27,18 @@ features: [Reflect.construct]
|
||||
var calls = 0;
|
||||
|
||||
function NewTarget() {}
|
||||
|
||||
function Target(a, b) {
|
||||
assert.sameValue(new.target, NewTarget);
|
||||
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);
|
||||
assert.sameValue(obj.sum, 7, "`construct` trap is `null`");
|
||||
assert.sameValue(calls, 1, "target is called once");
|
||||
|
@ -16,10 +16,13 @@ features: [Reflect.construct]
|
||||
var calls = 0;
|
||||
|
||||
function NewTarget() {}
|
||||
|
||||
function Target(a, b) {
|
||||
assert.sameValue(new.target, NewTarget);
|
||||
calls += 1;
|
||||
return {sum: a + b};
|
||||
return {
|
||||
sum: a + b
|
||||
};
|
||||
}
|
||||
|
||||
var P = new Proxy(Target, {});
|
||||
|
@ -27,13 +27,18 @@ features: [Reflect.construct]
|
||||
var calls = 0;
|
||||
|
||||
function NewTarget() {}
|
||||
|
||||
function Target(a, b) {
|
||||
assert.sameValue(new.target, NewTarget);
|
||||
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);
|
||||
assert.sameValue(obj.sum, 7, "`construct` trap is `undefined`");
|
||||
assert.sameValue(calls, 1, "target is called once");
|
||||
|
@ -22,6 +22,8 @@ features: [cross-realm]
|
||||
var other = $262.createRealm().global;
|
||||
var C = new other.Function();
|
||||
// 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);
|
||||
|
@ -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);
|
||||
|
||||
var pParent = Object.create(new Proxy(target, {}));
|
||||
|
@ -13,7 +13,9 @@ info: |
|
||||
---*/
|
||||
|
||||
var _target, _handler, _prop;
|
||||
var target = {attr: 1};
|
||||
var target = {
|
||||
attr: 1
|
||||
};
|
||||
var handler = {
|
||||
getOwnPropertyDescriptor: function(t, prop) {
|
||||
_target = t;
|
||||
|
@ -16,7 +16,9 @@ features: [cross-realm]
|
||||
var OProxy = $262.createRealm().global.Proxy;
|
||||
|
||||
var p = new OProxy({}, {
|
||||
getOwnPropertyDescriptor: function() { return null; }
|
||||
getOwnPropertyDescriptor: function() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
|
@ -18,7 +18,9 @@ var target = {};
|
||||
|
||||
var p = new Proxy(target, {
|
||||
getOwnPropertyDescriptor: function(t, prop) {
|
||||
var foo = { bar: 1 };
|
||||
var foo = {
|
||||
bar: 1
|
||||
};
|
||||
|
||||
return Object.getOwnPropertyDescriptor(foo, "bar");
|
||||
}
|
||||
|
@ -14,7 +14,9 @@ info: |
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
var target = {attr: 1};
|
||||
var target = {
|
||||
attr: 1
|
||||
};
|
||||
var p = new Proxy(target, {});
|
||||
|
||||
var proxyDesc = Object.getOwnPropertyDescriptor(p, "attr");
|
||||
|
@ -22,7 +22,9 @@ info: |
|
||||
|
||||
---*/
|
||||
|
||||
var prot = { foo: 1 };
|
||||
var prot = {
|
||||
foo: 1
|
||||
};
|
||||
var p = new Proxy({}, {
|
||||
getPrototypeOf: function() {
|
||||
return prot;
|
||||
|
@ -25,7 +25,9 @@ info: |
|
||||
...
|
||||
---*/
|
||||
|
||||
var target = Object.create({ foo: 1 });
|
||||
var target = Object.create({
|
||||
foo: 1
|
||||
});
|
||||
|
||||
var p = new Proxy(target, {
|
||||
getPrototypeOf: function() {
|
||||
|
@ -13,7 +13,9 @@ info: |
|
||||
a. Return trapResult.
|
||||
---*/
|
||||
|
||||
var p = new Proxy({attr: 42}, {
|
||||
var p = new Proxy({
|
||||
attr: 42
|
||||
}, {
|
||||
ownKeys: function() {
|
||||
return ["foo", "bar"];
|
||||
}
|
||||
|
@ -25,7 +25,9 @@ info: |
|
||||
|
||||
var p = new Proxy({}, {
|
||||
ownKeys() {
|
||||
return [[]];
|
||||
return [
|
||||
[]
|
||||
];
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -19,7 +19,9 @@ features: [cross-realm]
|
||||
---*/
|
||||
|
||||
var OProxy = $262.createRealm().global.Proxy;
|
||||
var p = new OProxy({attr:1}, {
|
||||
var p = new OProxy({
|
||||
attr: 1
|
||||
}, {
|
||||
ownKeys: {}
|
||||
});
|
||||
|
||||
|
@ -16,7 +16,9 @@ info: |
|
||||
4. If IsCallable(func) is false, throw a TypeError exception.
|
||||
---*/
|
||||
|
||||
var p = new Proxy({attr:1}, {
|
||||
var p = new Proxy({
|
||||
attr: 1
|
||||
}, {
|
||||
ownKeys: {}
|
||||
});
|
||||
|
||||
|
@ -16,4 +16,3 @@ description: >
|
||||
assert.throws(TypeError, function() {
|
||||
Proxy({}, {});
|
||||
});
|
||||
|
||||
|
@ -14,4 +14,6 @@ info: |
|
||||
var revocationFunction = Proxy.revocable({}, {}).revoke;
|
||||
|
||||
assert.sameValue(Object.prototype.hasOwnProperty.call(revocationFunction, "prototype"), false);
|
||||
assert.throws(TypeError, function() { new revocationFunction(); });
|
||||
assert.throws(TypeError, function() {
|
||||
new revocationFunction();
|
||||
});
|
||||
|
@ -19,7 +19,9 @@ var target = {
|
||||
}
|
||||
};
|
||||
|
||||
var p = new Proxy(target, { set: null });
|
||||
var p = new Proxy(target, {
|
||||
set: null
|
||||
});
|
||||
p.attr = 1;
|
||||
assert.sameValue(context, p);
|
||||
|
||||
|
@ -15,7 +15,9 @@ info: |
|
||||
|
||||
var _handler, _target, _value;
|
||||
var target = {};
|
||||
var val = {foo: 1};
|
||||
var val = {
|
||||
foo: 1
|
||||
};
|
||||
var handler = {
|
||||
setPrototypeOf: function(t, v) {
|
||||
_handler = this;
|
||||
|
@ -18,5 +18,7 @@ var p = new Proxy({}, {
|
||||
});
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Object.setPrototypeOf(p, {value: 1});
|
||||
Object.setPrototypeOf(p, {
|
||||
value: 1
|
||||
});
|
||||
});
|
||||
|
@ -32,30 +32,44 @@ var p = new Proxy(target, {
|
||||
|
||||
var result;
|
||||
|
||||
result = Reflect.setPrototypeOf(p, { attr: false });
|
||||
result = Reflect.setPrototypeOf(p, {
|
||||
attr: false
|
||||
});
|
||||
assert.sameValue(result, false, "false");
|
||||
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(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(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(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(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(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(called, 0, "NaN - isExtensible is not called");
|
||||
|
@ -36,31 +36,43 @@ var p = new Proxy(target, {
|
||||
var result;
|
||||
|
||||
called = 0;
|
||||
result = Reflect.setPrototypeOf(p, { attr: true });
|
||||
result = Reflect.setPrototypeOf(p, {
|
||||
attr: true
|
||||
});
|
||||
assert.sameValue(result, true, "true");
|
||||
assert.sameValue(called, 1, "true - isExtensible is called");
|
||||
|
||||
called = 0;
|
||||
result = Reflect.setPrototypeOf(p, { attr: "false" });
|
||||
result = Reflect.setPrototypeOf(p, {
|
||||
attr: "false"
|
||||
});
|
||||
assert.sameValue(result, true, "string");
|
||||
assert.sameValue(called, 1, "string - isExtensible is called");
|
||||
|
||||
called = 0;
|
||||
result = Reflect.setPrototypeOf(p, { attr: 42 });
|
||||
result = Reflect.setPrototypeOf(p, {
|
||||
attr: 42
|
||||
});
|
||||
assert.sameValue(result, true, "42");
|
||||
assert.sameValue(called, 1, "number - isExtensible is called");
|
||||
|
||||
called = 0;
|
||||
result = Reflect.setPrototypeOf(p, { attr: p });
|
||||
result = Reflect.setPrototypeOf(p, {
|
||||
attr: p
|
||||
});
|
||||
assert.sameValue(result, true, "p");
|
||||
assert.sameValue(called, 1, "object - isExtensible is called");
|
||||
|
||||
called = 0;
|
||||
result = Reflect.setPrototypeOf(p, { attr: [] });
|
||||
result = Reflect.setPrototypeOf(p, {
|
||||
attr: []
|
||||
});
|
||||
assert.sameValue(result, true, "[]");
|
||||
assert.sameValue(called, 1, "[] - isExtensible is called");
|
||||
|
||||
called = 0;
|
||||
result = Reflect.setPrototypeOf(p, { attr: Symbol(1) });
|
||||
result = Reflect.setPrototypeOf(p, {
|
||||
attr: Symbol(1)
|
||||
});
|
||||
assert.sameValue(result, true, "symbol");
|
||||
assert.sameValue(called, 1, "symbol - isExtensible is called");
|
||||
|
Loading…
x
Reference in New Issue
Block a user