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:
Your NameandClaude Opus 5.5 committed 2026-11-12 23:30:05 +01:00
1 parent 910bde692a
commit 300d767124
28 files changed
+1373 -65

No files matched your search

+7
View File
@@ -119,3 +119,10 @@ fn import_paths_going_up_keep_their_dots() {
let src = "import ...engine.engine\nimport ..side\nimport a.b\n\nfunc main() {\n for i in 0..3 { print(i) }\n}\n";
assert_eq!(fmt(src), src);
}
#[test]
fn bit_operators_and_defer() {
let src = "func main() {\nvar a=0xff&~0b1|1<<4>>2^3\na<<=1\na>>=1\na&=3\na|=4\na^=5\ndefer print(a)\ndefer{\nprint(-a)\n}\n}\n";
let want = "func main() {\n var a = 0xff & ~0b1 | 1 << 4 >> 2 ^ 3\n a <<= 1\n a >>= 1\n a &= 3\n a |= 4\n a ^= 5\n defer print(a)\n defer {\n print(-a)\n }\n}\n";
assert_eq!(fmt(src), want);
}