Add tests for [[Description]] of Intl [[FallbackSymbol]]

If normative optional is implemented and [[FallbackSymbol]] is used, its description should be "IntlLegacyConstructedSymbol"
This commit is contained in:
Yusuke Suzuki 2020-10-31 00:47:08 -07:00 committed by Rick Waldron
parent 3c58228465
commit 20b11bee0f
4 changed files with 96 additions and 0 deletions

View File

@ -0,0 +1,31 @@
// Copyright 2020 Apple Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-unwrapdatetimeformat
description: >
Tests that [[FallbackSymbol]]'s [[Description]] is "IntlLegacyConstructedSymbol" if normative optional is implemented.
author: Yusuke Suzuki
---*/
let object = new Intl.DateTimeFormat();
let newObject = Intl.DateTimeFormat.call(object);
let symbol = null;
let error = null;
try {
let proxy = new Proxy(newObject, {
get(target, property) {
symbol = property;
return target[property];
}
});
Intl.DateTimeFormat.prototype.resolvedOptions.call(proxy);
} catch (e) {
// If normative optional is not implemented, an error will be thrown.
error = e;
assert(error instanceof TypeError);
}
if (error === null) {
assert.sameValue(typeof symbol, "symbol");
assert.sameValue(symbol.description, "IntlLegacyConstructedSymbol");
}

View File

@ -0,0 +1,17 @@
// Copyright 2020 Apple Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-intl.datetimeformat
description: >
Tests that [[FallbackSymbol]]'s [[Description]] is "IntlLegacyConstructedSymbol" if normative optional is implemented.
author: Yusuke Suzuki
---*/
let object = new Intl.DateTimeFormat();
let newObject = Intl.DateTimeFormat.call(object);
let symbols = Object.getOwnPropertySymbols(newObject);
if (symbols.length !== 0) {
assert.sameValue(symbols.length, 1);
assert.sameValue(symbols[0].description, "IntlLegacyConstructedSymbol");
}

View File

@ -0,0 +1,31 @@
// Copyright 2020 Apple Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-unwrapnumberformat
description: >
Tests that [[FallbackSymbol]]'s [[Description]] is "IntlLegacyConstructedSymbol" if normative optional is implemented.
author: Yusuke Suzuki
---*/
let object = new Intl.NumberFormat();
let newObject = Intl.NumberFormat.call(object);
let symbol = null;
let error = null;
try {
let proxy = new Proxy(newObject, {
get(target, property) {
symbol = property;
return target[property];
}
});
Intl.NumberFormat.prototype.resolvedOptions.call(proxy);
} catch (e) {
// If normative optional is not implemented, an error will be thrown.
error = e;
assert(error instanceof TypeError);
}
if (error === null) {
assert.sameValue(typeof symbol, "symbol");
assert.sameValue(symbol.description, "IntlLegacyConstructedSymbol");
}

View File

@ -0,0 +1,17 @@
// Copyright 2020 Apple Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-intl.numberformat
description: >
Tests that [[FallbackSymbol]]'s [[Description]] is "IntlLegacyConstructedSymbol" if normative optional is implemented.
author: Yusuke Suzuki
---*/
let object = new Intl.NumberFormat();
let newObject = Intl.NumberFormat.call(object);
let symbols = Object.getOwnPropertySymbols(newObject);
if (symbols.length !== 0) {
assert.sameValue(symbols.length, 1);
assert.sameValue(symbols[0].description, "IntlLegacyConstructedSymbol");
}