mirror of
https://github.com/voltrevo/ValueScript.git
synced 2026-01-13 07:28:03 -05:00
Update test
This commit is contained in:
@@ -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;
|
||||
}
|
||||
25
inputs/passing/copyCounting/subscriptAssignment.ts
Normal file
25
inputs/passing/copyCounting/subscriptAssignment.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user