makepad/libs/relax/compiler/tests/const_param_env.rs
Admin b22a714840 makepad run: the Rust JIT (libs/relax) and makepad-remote
The JIT that runs makepad apps from source: lexer, front end, type checker,
lazy borrow checker (Gandalf; `--check-first` opts in), codegen, session and
warm/cold caches keyed by compiler stamp, provided crates bound late,
startup images, live patching. User-facing name is `makepad run` (binary
`makepad`, MAKEPAD_RUN_* env, ~/.makepad-run); libs/relax stays the internal
library name. `makepad check` reports rustc-style diagnostics with rustc
error codes and checks a whole workspace (`--workspace`). Runs on macOS,
Linux, Windows and Android. makepad-remote: one tool schema for apps and the
WM (app/1): grabs, captures, traces, frame profiles and tweaks.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-13 12:26:21 +02:00

35 lines
1.2 KiB
Rust

#[path = "const_param_env/src/lib.rs"]
mod reduced;
#[test]
fn nested_const_closures_deduplicate_and_flush() {
let sort = reduced::ExternalSort(vec![[1, 0], [1, 1], [2, 0], [3, 0]]);
assert_eq!(reduced::indexed(sort, 1).unwrap(), vec![vec![1, 0], vec![2, 0], vec![3, 0]]);
assert_eq!(reduced::indexed(reduced::ExternalSort::<2>(Vec::new()), 1).unwrap(), Vec::<Vec<u8>>::new());
}
#[test]
fn impl_const_environment_reaches_scoped_worker() {
let mut sort = reduced::ExternalSort::<3>(Vec::new());
std::thread::scope(|scope| {
let feed = reduced::Feed::start(scope, &mut sort);
feed.send(vec![[1, 2, 3], [4, 5, 6]]);
feed.join();
});
assert_eq!(sort.0, vec![[1, 2, 3], [4, 5, 6]]);
let rows = reduced::Rows(sort.0);
assert_eq!(rows.bytes(), rows.0.capacity() * 3);
}
#[test]
fn substituted_callees_keep_caller_const_types() {
assert_eq!(reduced::forwarded::<true, 3>([7, 8, 9]), ([7, 8, 9], [7, 8, 9]));
assert_eq!(reduced::forwarded::<false, 0>([]), ([], []));
}
#[test]
fn substituted_comparisons_resolve_with_const_clauses() {
assert!(reduced::ordered([1, 2], [1, 2]));
assert!(reduced::ordered([1, 2], [1, 3]));
assert!(!reduced::ordered([1, 3], [1, 2]));
}