nondescript/tests/ampersand.nds

29 lines
475 B
Plaintext

// intended use cases of ampersand:
var x = @[1, 2, 3, 4, 5];
x[0] = 0 & [2] = 0;
x[5] = 1 & [6] = 0 & [7] = 3 & [7] = 2;
//expect:@[ 0.0, 2.0, 0.0, 4.0, 5.0, 1.0, 0.0, 2.0 ]
print (x);
// for tables with dot syntax
var table = @{};
table.one = 1 &.two = 2 &.three = 3 &.four = 4;
print(table.three);
//expect:3.0
// not very useful but still must be correct behavior tests:
// change of precedence where interjected
var y = 5 + 1 & * 3;
//expect:18.0
print (y);