1describe("unittests:: evaluation:: templateLiteral", () => { 2 it("toString() over valueOf()", () => { 3 const result = evaluator.evaluateTypeScript(` 4 class C { 5 toString() { 6 return "toString"; 7 } 8 valueOf() { 9 return "valueOf"; 10 } 11 } 12 13 export const output = \`\${new C}\`; 14 `); 15 assert.strictEqual(result.output, "toString"); 16 }); 17 18 it("correct evaluation order", () => { 19 const result = evaluator.evaluateTypeScript(` 20 class C { 21 counter: number; 22 23 constructor() { 24 this.counter = 0; 25 } 26 27 get foo() { 28 this.counter++; 29 return { 30 toString: () => this.counter++, 31 }; 32 } 33 } 34 35 const c = new C; 36 export const output = \`\${c.foo} \${c.foo}\`; 37 `); 38 assert.strictEqual(result.output, "1 3"); 39 }); 40}); 41