Update test

This commit is contained in:
Andrew Morris
2023-06-22 17:57:46 +10:00
parent 62aaa57b7d
commit fd2dbb02df
2 changed files with 25 additions and 16 deletions

View File

@@ -1,16 +0,0 @@
//! test_output(3)
// Should be: 2
/// <reference path="../../../concept-code/vs.d.ts" />
export default function main() {
const x = Debug.makeCopyCounter("x");
let obj: Record<string, unknown> = { x }; // First copy
obj.y = "y"; // No extra copy
let arr: unknown[] = [x]; // Second copy
arr[1] = "y"; // No extra copy
return x.count;
}

View File

@@ -0,0 +1,25 @@
//! test_output(0)
/// <reference path="../../../concept-code/vs.d.ts" />
export default function main() {
return measure(true) - measure(false);
}
function measure(assign: boolean) {
const x = Debug.makeCopyCounter("x");
let obj: Record<string, unknown> = { x };
if (assign) {
obj.y = "y";
}
let arr: unknown[] = [x];
if (assign) {
arr[1] = "y";
}
return x.count;
}