ZeroJS
README.md
zerojs_language tests
Language and host-facing behaviour scripts rely on: optional chaining (?.), nullish coalescing (??) and the logical assignments (??=, ||=, &&=), what an error prints as, what console writes for an object, an array or an error, and what Date.now() and performance.now() read.
Every language case runs on both tiers a VM can execute with, the compiled tier and the interpreter, and expects the same answer from each.
| Test | What it holds |
|---|---|
optional_chaining_reads_through_nil | a?.b, a?.[k], f?.(x) give undefined for a null or undefined base, skip the rest of the chain and the arguments, keep this, and parse a?.5:1 as a conditional. |
optional_chaining_is_refused_as_a_target | A chain is a SyntaxError as an assignment, update or new target and before a tagged template. |
nullish_coalescing_keeps_false_and_zero | ?? replaces only null and undefined, never evaluates its right side otherwise, and refuses mixing with || and && unparenthesised. |
logical_assignment_assigns_only_when_it_applies | ??=, ||= and &&= evaluate the right side and write only when the current value calls for it. |
an_error_prints_its_message | String(e), `${e}`, "" + e and e.toString() read <name>: <message> for built-in errors and errors the runtime raises. |
console_log_prints_objects_and_arrays_readably | objects, arrays, nested values, errors, functions, Map, Set and cycles print the way a JavaScript console prints them, bounded in depth and length. |
date_now_moves_within_one_frame | Date.now() follows the wall clock between two reads with no engine frame between them. |
date_now_tracks_the_wall_clock | Date.now() stays inside the wall second os.time() reports. |
date_now_moves_across_an_await | Date.now() read before and after an awaited timer differs by about the timer. |
performance_now_is_monotonic | performance.now() never goes backwards and counts milliseconds. |