Skip to content

Commit f6f80a6

Browse files
committed
wip: move comments above to avoid output in errors
1 parent b7b9688 commit f6f80a6

10 files changed

+61
-30
lines changed

tests/contracts/reference_errors/ArrayInObjWithAliasMutation.algo.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@ export class ArrayInObjWithAliasMutation extends Contract {
66
const alias = val;
77
const objWithVal: { arr: uint64[] } = { arr: val };
88

9-
assert(objWithVal.arr[1] === 2); // Works because nothing has been made stale yet (no mutations)
9+
// Works because nothing has been made stale yet (no mutations)
10+
assert(objWithVal.arr[1] === 2);
1011

11-
alias[0] = 5; // Invalidate other references
12+
// Invalidate other references
13+
alias[0] = 5;
1214

13-
assert(objWithVal.arr[2] === 3); // Error because now objWithVal is stale
15+
// Error because now objWithVal is stale
16+
assert(objWithVal.arr[2] === 3);
1417
}
1518
}

tests/contracts/reference_errors/ArrayInObjWithNestedRefMutation.algo.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ export class ArrayInObjWithNestedRefMutation extends Contract {
55
const val: uint64[] = [1, 2, 3];
66
const objWithVal: { foo: uint64[][] } = { foo: [val] };
77

8-
assert(val[1] === 2); // Works because nothing has been made stale yet (no mutations)
8+
// Works because nothing has been made stale yet (no mutations)
9+
assert(val[1] === 2);
910

10-
objWithVal.foo[0][0] = 4; // Invalidate other references
11+
// Invalidate other references
12+
objWithVal.foo[0][0] = 4;
1113

12-
assert(val[2] === 3); // Error because now arrWithVal is stale
14+
// Error because now objWithVal is stale
15+
assert(val[2] === 3);
1316
}
1417
}

tests/contracts/reference_errors/ArrayInObjWithRefMutation.algo.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ export class ArrayInObjWithRefMutation extends Contract {
55
const val: uint64[] = [1, 2, 3];
66
const objWithVal: { arr: uint64[] } = { arr: val };
77

8-
assert(val[1] === 2); // Works because nothing has been made stale yet (no mutations)
8+
// Works because nothing has been made stale yet (no mutations)
9+
assert(val[1] === 2);
910

10-
objWithVal.arr[0] = 5; // Invalidate other references
11+
// Invalidate other references
12+
objWithVal.arr[0] = 5;
1113

12-
assert(val[2] === 3); // Error because now val is stale
14+
// Error because now val is stale
15+
assert(val[2] === 3);
1316
}
1417
}

tests/contracts/reference_errors/ArrayWithAliasMutation.algo.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@ export class ArrayWithAliasMutation extends Contract {
55
const val: uint64[] = [1, 2, 3];
66
const alias = val;
77
const arrWithVal: uint64[][] = [val];
8-
assert(arrWithVal[0][1] === 2); // Works because nothing has been made stale yet (no mutations)
98

10-
alias[0] = 5; // Invalidate other references
9+
// Works because nothing has been made stale yet (no mutations)
10+
assert(arrWithVal[0][1] === 2);
1111

12-
assert(arrWithVal[0][2] === 3); // Error because now arrWithVal is stale
12+
// Invalidate other references
13+
alias[0] = 5;
14+
15+
// Error because now arrWithVal is stale
16+
assert(arrWithVal[0][2] === 3);
1317
}
1418
}

tests/contracts/reference_errors/ArrayWithFnMutation.algo.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ export class ArrayWithFnMutation extends Contract {
88
const alias = val;
99
const arrWithVal: uint64[][] = [val];
1010

11-
assert(arrWithVal[0][1] === 2); // Works because nothing has been made stale yet (no mutations)
11+
// Works because nothing has been made stale yet (no mutations)
12+
assert(arrWithVal[0][1] === 2);
1213

13-
this.someFun(alias); // Invalidate all references
14+
// Invalidate all references
15+
this.someFun(alias);
1416

15-
assert(arrWithVal[0][2] === 3); // Error because now all references are stale
17+
// Error because now all references are stale
18+
assert(arrWithVal[0][2] === 3);
1619
}
1720
}

tests/contracts/reference_errors/ArrayWithNestedRefMutation.algo.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ export class ArrayWithNestedRefMutation extends Contract {
55
const val: uint64[] = [1, 2, 3];
66
const arrWithVal: uint64[][][] = [[val]];
77

8-
assert(val[1] === 2); // Works because nothing has been made stale yet (no mutations)
8+
// Works because nothing has been made stale yet (no mutations)
9+
assert(val[1] === 2);
910

10-
arrWithVal[0][0][0] = 4; // Invalidate other references
11+
// Invalidate other references
12+
arrWithVal[0][0][0] = 4;
1113

12-
assert(val[2] === 3); // Error because now arrWithVal is stale
14+
// Error because now arrWithVal is stale
15+
assert(val[2] === 3);
1316
}
1417
}

tests/contracts/reference_errors/ObjAssignmentWithAliasMutation.algo.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ export class ObjAssignmentWithAliasMutation extends Contract {
77
const objWithVal: { bar: { foo: uint64 } } = { bar: { foo: 123 } };
88
objWithVal.bar = val;
99

10-
assert(objWithVal.bar.foo === 1337); // Works because nothing has been made stale yet (no mutations)
10+
// Works because nothing has been made stale yet (no mutations)
11+
assert(objWithVal.bar.foo === 1337);
1112

12-
alias.foo = 7331; // Invalidate other references
13+
// Invalidate other references
14+
alias.foo = 7331;
1315

14-
assert(objWithVal.bar.foo === 7331); // Error because now objWithVal is stale
16+
// Error because now objWithVal is stale
17+
assert(objWithVal.bar.foo === 7331);
1518
}
1619
}

tests/contracts/reference_errors/ObjWithAliasMutation.algo.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@ export class ObjWithAliasMutation extends Contract {
66
const alias = val;
77
const objWithVal: { bar: { foo: uint64 } } = { bar: val };
88

9-
assert(objWithVal.bar.foo === 1337); // Works because nothing has been made stale yet (no mutations)
9+
// Works because nothing has been made stale yet (no mutations)
10+
assert(objWithVal.bar.foo === 1337);
1011

11-
alias.foo = 7331; // Invalidate other references
12+
// Invalidate other references
13+
alias.foo = 7331;
1214

13-
assert(objWithVal.bar.foo === 7331); // Error because now objWithVal is stale
15+
// Error because now objWithVal is stale
16+
assert(objWithVal.bar.foo === 7331);
1417
}
1518
}

tests/contracts/reference_errors/ObjWithNestedRefMutation.algo.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ export class ObjWithNestedRefMutation extends Contract {
55
const val: { foo: uint64 } = { foo: 1337 };
66
const objWithVal: { baz: { bar: { foo: uint64 } } } = { baz: { bar: val } };
77

8-
assert(val.foo === 1337); // Works because nothing has been made stale yet (no mutations)
8+
// Works because nothing has been made stale yet (no mutations)
9+
assert(val.foo === 1337);
910

10-
objWithVal.baz.bar.foo = 7331; // Invalidate other references
11+
// Invalidate other references
12+
objWithVal.baz.bar.foo = 7331;
1113

12-
assert(val.foo === 7331); // Error because now objWithVal is stale
14+
// Error because now objWithVal is stale
15+
assert(val.foo === 7331);
1316
}
1417
}

tests/contracts/reference_errors/ObjWithRefMutation.algo.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ export class ObjWithRefMutation extends Contract {
55
const val: { foo: uint64 } = { foo: 1337 };
66
const objWithVal: { bar: { foo: uint64 } } = { bar: val };
77

8-
assert(val.foo === 1337); // Works because nothing has been made stale yet (no mutations)
8+
// Works because nothing has been made stale yet (no mutations)
9+
assert(val.foo === 1337);
910

10-
objWithVal.bar.foo = 7331; // Invalidate other references
11+
// Invalidate other references
12+
objWithVal.bar.foo = 7331;
1113

12-
assert(val.foo === 7331); // Error because now objWithVal is stale
14+
// Error because now objWithVal is stale
15+
assert(val.foo === 7331);
1316
}
1417
}

0 commit comments

Comments
 (0)