mirror of
https://github.com/tc39/test262.git
synced 2025-07-26 07:25:15 +02:00
TemplateMap: split TemplateMap cache test into own file
This commit is contained in:
parent
9388d6ad70
commit
2f201e5561
@ -0,0 +1,40 @@
|
|||||||
|
// Copyright (C) 2018 Andrea Giammarchi. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-gettemplateobject
|
||||||
|
description: >
|
||||||
|
Template objects are canonicalized separately for each realm using its Realm Record's [[TemplateMap]]. Each [[Site]] value is a Parse Node that is a TemplateLiteral
|
||||||
|
info: |
|
||||||
|
|
||||||
|
Let rawStrings be TemplateStrings of templateLiteral with argument true.
|
||||||
|
Let realm be the current Realm Record.
|
||||||
|
Let templateRegistry be realm.[[TemplateMap]].
|
||||||
|
For each element e of templateRegistry, do
|
||||||
|
If e.[[Site]] is the same Parse Node as templateLiteral, then
|
||||||
|
Return e.[[Array]].
|
||||||
|
|
||||||
|
---*/
|
||||||
|
var expect;
|
||||||
|
var cache = [];
|
||||||
|
function sameSite() {
|
||||||
|
tag`${Math.random()}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function tag(parameter) {
|
||||||
|
if (!expect) {
|
||||||
|
expect = parameter;
|
||||||
|
}
|
||||||
|
cache.push(parameter);
|
||||||
|
}
|
||||||
|
|
||||||
|
sameSite();
|
||||||
|
sameSite();
|
||||||
|
tag`${1}`;
|
||||||
|
sameSite();
|
||||||
|
sameSite();
|
||||||
|
|
||||||
|
assert(cache[0] === expect);
|
||||||
|
assert(cache[1] === expect);
|
||||||
|
assert(cache[2] !== expect);
|
||||||
|
assert(cache[3] === expect);
|
||||||
|
assert(cache[4] === expect);
|
@ -1,18 +1,14 @@
|
|||||||
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
es6id: 12.3.7
|
esid: sec-gettemplateobject
|
||||||
description: Properties of the template object
|
description: Properties of the template object
|
||||||
info: |
|
info: |
|
||||||
The first argument to a tagged template should be a template object as
|
The first argument to a tagged template should be a template object as
|
||||||
defined by the GetTemplateObject abstract operation.
|
defined by the GetTemplateObject abstract operation.
|
||||||
includes: [propertyHelper.js]
|
includes: [propertyHelper.js]
|
||||||
---*/
|
---*/
|
||||||
var templateObject, sameObject;
|
var templateObject
|
||||||
|
|
||||||
function sameSite() {
|
|
||||||
tag`${Math.random()}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function tag(parameter) {
|
function tag(parameter) {
|
||||||
templateObject = parameter;
|
templateObject = parameter;
|
||||||
@ -44,13 +40,3 @@ verifyNotConfigurable(templateObject.raw, '0');
|
|||||||
verifyNotEnumerable(templateObject.raw, 'length');
|
verifyNotEnumerable(templateObject.raw, 'length');
|
||||||
verifyNotWritable(templateObject.raw, 'length')
|
verifyNotWritable(templateObject.raw, 'length')
|
||||||
verifyNotConfigurable(templateObject.raw, 'length');
|
verifyNotConfigurable(templateObject.raw, 'length');
|
||||||
|
|
||||||
sameSite();
|
|
||||||
sameObject = templateObject;
|
|
||||||
sameSite();
|
|
||||||
|
|
||||||
assert(
|
|
||||||
templateObject === sameObject,
|
|
||||||
'Normative: Cache templates per site, rather than by contents'
|
|
||||||
// https://github.com/tc39/ecma262/pull/890
|
|
||||||
);
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user