diff --git a/test/language/expressions/tagged-template/template-object-template-map.js b/test/language/expressions/tagged-template/template-object-template-map.js new file mode 100644 index 0000000000000000000000000000000000000000..0b58e61ea9cc915d0bef2cdfb9cf3ffbf8bb4f89 --- /dev/null +++ b/test/language/expressions/tagged-template/template-object-template-map.js @@ -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); diff --git a/test/language/expressions/tagged-template/template-object.js b/test/language/expressions/tagged-template/template-object.js index 207e68066660354802ac11349e310539681280f6..8e595ce87840fcc3282702e6dd520ce527957849 100644 --- a/test/language/expressions/tagged-template/template-object.js +++ b/test/language/expressions/tagged-template/template-object.js @@ -1,18 +1,14 @@ // Copyright (C) 2014 the V8 project authors. All rights reserved. // 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 info: | The first argument to a tagged template should be a template object as defined by the GetTemplateObject abstract operation. includes: [propertyHelper.js] ---*/ -var templateObject, sameObject; - -function sameSite() { - tag`${Math.random()}`; -} +var templateObject function tag(parameter) { templateObject = parameter; @@ -44,13 +40,3 @@ verifyNotConfigurable(templateObject.raw, '0'); verifyNotEnumerable(templateObject.raw, 'length'); verifyNotWritable(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 -);