mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-08 00:38:39 +09:00
parent
7bfe087f0c
commit
f9950a2c9c
8 changed files with 39 additions and 38 deletions
|
|
@ -17,7 +17,7 @@ function makeObject() {
|
|||
let tests = [
|
||||
{ name: "Ctor", object: new Ctor },
|
||||
{ name: "nested.Ctor", object: new nested.Ctor },
|
||||
{ name: "makeInstance/LexicalCtor", object: makeInstance() },
|
||||
{ name: "LexicalCtor", object: makeInstance() },
|
||||
{ name: null, object: {} },
|
||||
{ name: null, object: nested.object },
|
||||
{ name: null, object: makeObject() },
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ assertName(Foo, 'Foo</<');
|
|||
|
||||
/* various properties and such */
|
||||
var x = {fox: { bax: function(){} } };
|
||||
assertName(x.fox.bax, 'x.fox.bax');
|
||||
assertName(x.fox.bax, 'bax');
|
||||
var foo = {foo: {foo: {}}};
|
||||
foo.foo.foo = function(){};
|
||||
assertName(foo.foo.foo, 'foo.foo.foo');
|
||||
|
|
@ -48,20 +48,20 @@ var z = {
|
|||
foz: function() {
|
||||
var baz = function() {
|
||||
var y = {bay: function() {}};
|
||||
assertName(y.bay, 'z.foz/baz/y.bay');
|
||||
assertName(y.bay, 'bay');
|
||||
};
|
||||
assertName(baz, 'z.foz/baz');
|
||||
assertName(baz, 'baz');
|
||||
baz();
|
||||
}
|
||||
};
|
||||
assertName(z.foz, 'z.foz');
|
||||
assertName(z.foz, 'foz');
|
||||
z.foz();
|
||||
|
||||
var outer = function() {
|
||||
x.fox.bax.nx = function(){};
|
||||
var w = {fow: { baw: function(){} } };
|
||||
assertName(x.fox.bax.nx, 'outer/x.fox.bax.nx')
|
||||
assertName(w.fow.baw, 'outer/w.fow.baw');
|
||||
assertName(w.fow.baw, 'baw');
|
||||
};
|
||||
assertName(outer, 'outer');
|
||||
outer();
|
||||
|
|
@ -69,7 +69,7 @@ function Fuz(){};
|
|||
Fuz.prototype = {
|
||||
add: function() {}
|
||||
}
|
||||
assertName(Fuz.prototype.add, 'Fuz.prototype.add');
|
||||
assertName(Fuz.prototype.add, 'add');
|
||||
|
||||
var x = 1;
|
||||
x = function(){};
|
||||
|
|
@ -94,7 +94,7 @@ a.b = function() {
|
|||
assertName(arguments.callee, 'a.b<');
|
||||
return { a: function() {} }
|
||||
}();
|
||||
assertName(a.b.a, 'a.b</<.a');
|
||||
assertName(a.b.a, 'a');
|
||||
|
||||
a = {
|
||||
b: function(a) {
|
||||
|
|
@ -104,9 +104,9 @@ a = {
|
|||
return function() {};
|
||||
}
|
||||
};
|
||||
assertName(a.b, 'a.b');
|
||||
assertName(a.b(true), 'a.b/<')
|
||||
assertName(a.b(false), 'a.b/<')
|
||||
assertName(a.b, 'b');
|
||||
assertName(a.b(true), 'b/<')
|
||||
assertName(a.b(false), 'b/<')
|
||||
|
||||
function f(g) {
|
||||
assertName(g, 'x<');
|
||||
|
|
@ -116,7 +116,7 @@ var x = f(function () { return function() {}; });
|
|||
assertName(x, 'x</<');
|
||||
|
||||
var a = {'b': function(){}};
|
||||
assertName(a.b, 'a.b');
|
||||
assertName(a.b, 'b');
|
||||
|
||||
function g(f) {
|
||||
assertName(f, '');
|
||||
|
|
@ -138,15 +138,15 @@ a = {
|
|||
"\"\'quotes\'\"": function(){},
|
||||
"!@#$%": function(){}
|
||||
};
|
||||
assertName(a["embedded spaces"], 'a["embedded spaces"]');
|
||||
assertName(a["dots.look.like.property.references"], 'a["dots.look.like.property.references"]');
|
||||
assertName(a["\"\'quotes\'\""], 'a["\\\"\'quotes\'\\\""]');
|
||||
assertName(a["!@#$%"], 'a["!@#$%"]');
|
||||
assertName(a["embedded spaces"], 'embedded spaces');
|
||||
assertName(a["dots.look.like.property.references"], 'dots.look.like.property.references');
|
||||
assertName(a["\"\'quotes\'\""], '"\'quotes\'"');
|
||||
assertName(a["!@#$%"], '!@#$%');
|
||||
|
||||
a.b = {};
|
||||
a.b.c = {};
|
||||
a.b["c"]["d e"] = { f: { 1: { "g": { "h i": function() {} } } } };
|
||||
assertName(a.b.c["d e"].f[1].g["h i"], 'a.b.c["d e"].f[1].g["h i"]');
|
||||
assertName(a.b.c["d e"].f[1].g["h i"], 'h i');
|
||||
|
||||
this.m = function () {};
|
||||
assertName(m, "this.m");
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ root.eval(
|
|||
this.tests = [
|
||||
{ name: "Ctor", fn: () => new Ctor },
|
||||
{ name: "nested.Ctor", fn: () => new nested.Ctor },
|
||||
{ name: "makeInstance/LexicalCtor", fn: () => makeInstance() },
|
||||
{ name: "LexicalCtor", fn: () => makeInstance() },
|
||||
{ name: null, fn: () => ({}) },
|
||||
{ name: null, fn: () => (nested.object = {}) },
|
||||
{ name: null, fn: () => makeObject() },
|
||||
|
|
|
|||
|
|
@ -2,9 +2,8 @@
|
|||
|
||||
function uno() { return dos(); }
|
||||
const dos = () => tres.quattro();
|
||||
const tres = {
|
||||
quattro: () => saveStack()
|
||||
};
|
||||
let tres = {};
|
||||
tres.quattro = () => saveStack()
|
||||
|
||||
const frame = uno();
|
||||
|
||||
|
|
|
|||
|
|
@ -77,7 +77,8 @@ assertDeepEq(q, p);
|
|||
assertNotDeepEq(() => 1, () => 2);
|
||||
assertNotDeepEq((...x) => 1, x => 1);
|
||||
assertNotDeepEq(function f(){}, function g(){});
|
||||
var f1 = function () {}, f2 = function () {};
|
||||
// Avoid setting name property.
|
||||
var [f1, f2] = [function () {}, function () {}];
|
||||
assertDeepEq(f1, f1);
|
||||
assertDeepEq(f1, f2); // same text, close enough
|
||||
f1.prop = 1;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ assertEq(ErrorToString(function(){}), "");
|
|||
|
||||
var fn1 = function() {};
|
||||
fn1.message = "ohai";
|
||||
assertEq(ErrorToString(fn1), "ohai");
|
||||
assertEq(ErrorToString(fn1), "fn1: ohai");
|
||||
|
||||
var fn2 = function blerch() {};
|
||||
fn2.message = "fnord";
|
||||
|
|
@ -35,7 +35,7 @@ assertEq(ErrorToString(fn2), "blerch: fnord");
|
|||
|
||||
var fn3 = function() {};
|
||||
fn3.message = "";
|
||||
assertEq(ErrorToString(fn3), "");
|
||||
assertEq(ErrorToString(fn3), "fn3");
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
|
|
|||
|
|
@ -174,27 +174,29 @@ testName(ExtendedExpr3, "base", false, false, false);
|
|||
|
||||
// Anonymous class expressions don't get name properties unless specified in a
|
||||
// static manner.
|
||||
let Anon = class {
|
||||
// Use property assignment to avoid setting name property.
|
||||
let tmp = {};
|
||||
let Anon = tmp.value = class {
|
||||
constructor() {}
|
||||
};
|
||||
testName(Anon, "", false, false, false);
|
||||
|
||||
let AnonDefault = class { };
|
||||
let AnonDefault = tmp.value = class { };
|
||||
testName(AnonDefault, "", false, false, false);
|
||||
|
||||
let AnonWithGetter = class {
|
||||
let AnonWithGetter = tmp.value = class {
|
||||
constructor() {}
|
||||
static get name() { return "base"; }
|
||||
};
|
||||
testName(AnonWithGetter, "base", false, true, false);
|
||||
|
||||
let AnonWithSetter = class {
|
||||
let AnonWithSetter = tmp.value = class {
|
||||
constructor() {}
|
||||
static set name(v) {}
|
||||
};
|
||||
testName(AnonWithSetter, undefined, false, false, true);
|
||||
|
||||
let AnonWithGetterSetter = class {
|
||||
let AnonWithGetterSetter = tmp.value = class {
|
||||
constructor() {}
|
||||
static get name() { return "base"; }
|
||||
static set name(v) {}
|
||||
|
|
@ -202,15 +204,15 @@ let AnonWithGetterSetter = class {
|
|||
testName(AnonWithGetterSetter, "base", false, true, true);
|
||||
|
||||
|
||||
let ExtendedAnon1 = class extends Anon {
|
||||
let ExtendedAnon1 = tmp.value = class extends Anon {
|
||||
constructor() {}
|
||||
};
|
||||
testName(ExtendedAnon1, "", false, false, false);
|
||||
|
||||
let ExtendedAnonDefault = class extends Anon { };
|
||||
let ExtendedAnonDefault = tmp.value = class extends Anon { };
|
||||
testName(ExtendedAnonDefault, "", false, false, false);
|
||||
|
||||
let ExtendedAnon2 = class extends AnonWithGetterSetter {
|
||||
let ExtendedAnon2 = tmp.value = class extends AnonWithGetterSetter {
|
||||
constructor() {}
|
||||
static get name() { return "extend"; }
|
||||
};
|
||||
|
|
@ -218,7 +220,7 @@ testName(ExtendedAnon2, "extend", false, true, false);
|
|||
delete ExtendedAnon2.name;
|
||||
testName(ExtendedAnon2, "base", false, false, false);
|
||||
|
||||
let ExtendedAnon3 = class extends AnonWithGetterSetter {
|
||||
let ExtendedAnon3 = tmp.value = class extends AnonWithGetterSetter {
|
||||
constructor() {}
|
||||
static set name(v) {}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -27,10 +27,9 @@ o = {get case() { }, set case(v) {}}
|
|||
assertEq(name(o, "case", true), "get case");
|
||||
assertEq(name(o, "case", false), "set case");
|
||||
|
||||
// Congratulations on implementing these!
|
||||
assertEq(name({get ["a"]() {}}, "a", true), "");
|
||||
assertEq(name({get [123]() {}}, "123", true), "");
|
||||
assertEq(name({set ["a"](v) {}}, "a", false), "");
|
||||
assertEq(name({set [123](v) {}}, "123", false), "");
|
||||
assertEq(name({get ["a"]() {}}, "a", true), "get a");
|
||||
assertEq(name({get [123]() {}}, "123", true), "get 123");
|
||||
assertEq(name({set ["a"](v) {}}, "a", false), "set a");
|
||||
assertEq(name({set [123](v) {}}, "123", false), "set 123");
|
||||
|
||||
reportCompare(true, true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue