Add bit operators, defer, list methods, rand, assert and rex test
- Bit operators & | ^ ~ << >> and their op= forms (Go precedence),
plus hex, binary and octal literals (0xff, 0b1010, 0o755)
- defer stmt / defer { ... }: runs when the block ends, last first,
also on return, ?, break and continue
- List methods insert, remove, clear, contains, index_of, reverse,
sort and sort_by (stable merge sort)
- rand module: int(a, b), float(), seed(n)
- assert(cond[, msg]) and `rex test`, which runs each test_ function
in its own process
- rex.toml marks a project's top folder: imports count from there
- Docs, formatter, LSP completions and editor grammars updated
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
910bde692a
commit
300d767124
28 files changed
+1373
-65
No files matched your search
+10
-2
@@ -226,8 +226,16 @@ fn error_const_needs_value() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn error_single_ampersand() {
|
||||
assert!(err("func f() { var a = b & c }").msg.contains("&&"));
|
||||
fn bit_operators_bind_like_go() {
|
||||
// `&` and shifts go with `*`, `|` and `^` with `+`, all tighter than comparisons
|
||||
let p = parse("func f() { var a = b & 1 == 0 }").unwrap();
|
||||
let text = format!("{p:?}");
|
||||
let eq = text.find("op: Eq").unwrap();
|
||||
let and = text.find("op: BitAnd").unwrap();
|
||||
assert!(eq < and, "`==` should be the outer operator: {text}");
|
||||
let p = parse("func f() { var a = b | c << 2 }").unwrap();
|
||||
let text = format!("{p:?}");
|
||||
assert!(text.find("op: BitOr").unwrap() < text.find("op: Shl").unwrap(), "{text}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user