1// Copyright 2014 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5new BenchmarkSuite('Untagged', [1000], [
6  new Benchmark('Untagged-Simple', false, false, 0,
7                Untagged, UntaggedSetup, UntaggedTearDown),
8]);
9
10new BenchmarkSuite('LargeUntagged', [1000], [
11  new Benchmark('Untagged-Large', false, false, 0,
12                UntaggedLarge, UntaggedLargeSetup, UntaggedLargeTearDown),
13]);
14
15new BenchmarkSuite('Tagged', [1000], [
16  new Benchmark('TaggedRawSimple', false, false, 0,
17                TaggedRaw, TaggedRawSetup, TaggedRawTearDown),
18]);
19
20var result;
21var SUBJECT = 'Bob';
22var TARGET = 'Mary';
23var OBJECT = 'apple';
24
25function UntaggedSetup() {
26  result = undefined;
27}
28
29function Untagged() {
30  result = `${SUBJECT} gives ${TARGET} an ${OBJECT}.`;
31}
32
33function UntaggedTearDown() {
34  var expected = '' + SUBJECT + ' gives ' + TARGET + ' an ' + OBJECT + '.';
35  return result === expected;
36}
37
38
39// ----------------------------------------------------------------------------
40
41function UntaggedLargeSetup() {
42  result = undefined;
43}
44
45function UntaggedLarge() {
46  result = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus
47 aliquam, elit euismod vestibulum ${0}lacinia, arcu odio sagittis mauris, id
48 blandit dolor felis pretium nisl. Maecenas porttitor, nunc ut accumsan mollis,
49 arcu metus rutrum arcu, ${1}ut varius dolor lorem nec risus. Integer convallis
50 tristique ante, non pretium ante suscipit at. Sed egestas massa enim, convallis
51 fermentum neque vehicula ac. Donec imperdiet a tortor ac semper. Morbi accumsan
52 quam nec erat viverra iaculis. ${2}Donec a scelerisque cras amet.`;
53}
54
55function UntaggedLargeTearDown() {
56  var expected = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " +
57      "Vivamus\n aliquam, elit euismod vestibulum " + 0 + "lacinia, arcu odio" +
58      " sagittis mauris, id\n blandit dolor felis pretium nisl. Maecenas " +
59      "porttitor, nunc ut accumsan mollis,\n arcu metus rutrum arcu, " + 1 +
60      "ut varius dolor lorem nec risus. Integer convallis\n tristique ante, " +
61      "non pretium ante suscipit at. Sed egestas massa enim, convallis\n " +
62      "fermentum neque vehicula ac. Donec imperdiet a tortor ac semper. Morbi" +
63      " accumsan\n quam nec erat viverra iaculis. " + 2 + "Donec a " +
64      "scelerisque cras amet.";
65  return result === expected;
66}
67
68
69// ----------------------------------------------------------------------------
70
71
72function TaggedRawSetup() {
73  result = undefined;
74}
75
76function TaggedRaw() {
77  result = String.raw `${SUBJECT} gives ${TARGET} an ${OBJECT} \ud83c\udf4f.`;
78}
79
80function TaggedRawTearDown() {
81  var expected =
82      '' + SUBJECT + ' gives ' + TARGET + ' an ' + OBJECT + ' \\ud83c\\udf4f.';
83  return result === expected;
84}
85
86
87// ----------------------------------------------------------------------------
88