nondescript/tests/precedence.nds

35 lines
479 B
Plaintext
Raw Permalink Normal View History

2022-02-05 03:24:30 +01:00
// test for testing the relative precedence of expressions
// groupings
//expect:15.0
2022-02-07 05:35:07 +01:00
print (5 * (1 + 2));
2022-02-05 03:24:30 +01:00
//expect:11.0
2022-02-07 05:35:07 +01:00
print ((5 * 2) + 1);
2022-02-05 03:24:30 +01:00
//expect:-9.0
2022-02-07 05:35:07 +01:00
print (-((3 + 2) * 2) + 1);
2022-02-05 03:24:30 +01:00
// calls
// calls and indexes
2022-02-09 06:58:51 +01:00
var returnlist = proc() { @result
2022-02-05 03:24:30 +01:00
:result = @[];
:result[0] = 4;
:result[1] = 6;
:result[2] = 5;
:result[3] = 7;
};
//expect:5.0
2022-02-07 05:35:07 +01:00
print (returnlist()[2]);
2022-02-05 03:24:30 +01:00
// priority over unary
2022-02-09 06:58:51 +01:00
var truesayer = proc()
2022-02-09 06:47:00 +01:00
true
;
2022-02-05 03:24:30 +01:00
//expect:false
2022-02-07 05:35:07 +01:00
print (!truesayer());