diff options
author | Daniel Ehrenberg <littledan@chromium.org> | 2018-02-27 23:46:44 +0100 |
---|---|---|
committer | Leo Balter <leonardo.balter@gmail.com> | 2018-02-27 17:46:44 -0500 |
commit | 0b54908dba8d4fdad41e4c6216d13149f6ecf379 (patch) | |
tree | 3694142109480a74ef15f74dde099e96ce988c82 | |
parent | a01e2a3f031dc658ccd1ca42dcb392614c06c2a0 (diff) | |
download | qtdeclarative-testsuites-0b54908dba8d4fdad41e4c6216d13149f6ecf379.tar.gz |
Add test for eval-in-function template tags (#1457)
Thanks to Caitin Potter for highlighting this test case.
-rw-r--r-- | test/language/expressions/tagged-template/cache-eval-inner-function.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/language/expressions/tagged-template/cache-eval-inner-function.js b/test/language/expressions/tagged-template/cache-eval-inner-function.js new file mode 100644 index 000000000..4963d04c5 --- /dev/null +++ b/test/language/expressions/tagged-template/cache-eval-inner-function.js @@ -0,0 +1,35 @@ +// Copyright (C) 2018 Igalia, S. L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-gettemplateobject +description: Templates are cached by source location inside a function +info: > + Each time eval is called, it is a different site. However, a loop within + the eval is considered the same site. This is a regression test for an + issue that Caitlin Potter faced in implementations of the new template + caching semantics in both V8 and JSC. + + 1. For each element _e_ of _templateRegistry_, do + 1. If _e_.[[Site]] is the same Parse Node as _templateLiteral_, then + 1. Return _e_.[[Array]]. +---*/ + +let objs = []; +function tag(templateObject) { + objs.push(templateObject); +} + +for (let a = 0; a < 2; a++) { + eval("\ + (function() {\ + for (let b = 0; b < 2; b++) {\ + tag`${a}${b}`;\ + }\ + })();\ + "); +} + +assert.sameValue(objs[0], objs[1]); +assert.notSameValue(objs[1], objs[2]); +assert.sameValue(objs[2], objs[3]); + |