Interpreter Test Reference — JSON, Collections, and Arrays
These tests verify the complex value types: JSON (JsonObject/JsonArray/JsonToken/ JsonValue), the generic List and Dictionary collections, and fixed-size arrays. Each feature has a native-mirror test (pinning the exact reference/value semantics against Microsoft's runtime) plus script tests for the member APIs.
JSON
| Test |
What it verifies |
JsonNativeMirrorTests |
The native JSON semantics the interpreter must reproduce: assignment aliases (reference type), Clone isolates, Get on a missing key is false, WriteTo is compact and insertion-ordered, ReadFrom of invalid JSON preserves content, ReadFrom replaces shared content in place, duplicate-key Add errors, array Add/Count/Get/Insert/RemoveAt/Set/IndexOf, token kind probes, JsonValue lifecycle, alias visibility of SetValue/ReadFrom, and SelectToken. Native-mirrored. |
JsonObjectScriptTests |
JsonObject in scripts: Add, Contains, WriteTo, ReadFrom (valid and invalid), Remove, Replace, Get, SelectToken, the typed getters (GetInteger/GetText/GetBoolean/GetDecimal/GetObject/GetArray/GetValue/GetToken), the DefaultIfNotFound overloads, and the missing-key error. |
JsonArrayScriptTests |
JsonArray (0-based): Add, Count, Get, typed index getters, WriteTo, ReadFrom, Insert, RemoveAt, Set, IndexOf, SelectToken, the DefaultIfNotFound overload, and the out-of-range error. |
JsonTokenAndValueScriptTests |
JsonToken kind tests and casts (IsObject/AsObject, IsArray/AsArray, IsValue/AsValue), Clone, SelectToken; JsonValue SetValue/As* for each scalar type, IsNull/IsUndefined, AsToken, alias visibility, and the wrong-cast error. |
JsonSemanticsScriptTests |
Reference semantics in scripts: assignment aliases and Clone isolates; non-var parameters still share the object; ReadFrom inside a procedure replaces the caller's content; implicit JsonObject→JsonToken; a Json-returning procedure (and the empty {} default without exit); clear rebinds; and building nested structures. |
JsonChainingScriptTests |
Method chains resolve to the final link's type: t.AsValue().AsInteger(), j.GetValue('n').AsText(), three-link chains, a JSON link flowing into a Text method, chains inside conditions/arithmetic, and a chained receiver being a temporary (mutating Clone() leaves the source untouched). |
Collections
| Test |
What it verifies |
ListDictNativeMirrorTests |
Native List/Dictionary semantics: Lists are 1-based; Get out of range errors while two-arg Get is false; IndexOf, Contains, Insert, RemoveAt, Set, Remove, Reverse, GetRange; assignment aliases; foreach preserves insertion order; Dictionary Add/duplicate error, ContainsKey, Get, Set, Count, Remove, Keys/Values, and alias-on-assignment. Native-mirrored. |
ListScriptTests |
List members in scripts: Add, Count, Get (1-based, value and var overloads), IndexOf, Contains, Insert, RemoveAt, Set, Remove, Reverse, GetRange, LastIndexOf, aliasing and clear, list parameters and return; plus type-mismatch and out-of-bounds diagnostics. |
DictionaryScriptTests |
Dictionary members in scripts: Add, ContainsKey, Get (value and var), Set (replace and add), Count, Remove, Keys, Values, typed keys, aliasing; plus duplicate-key and missing-key diagnostics. |
ForEachScriptTests |
foreach over a List (Integer and Text), with break; over a JsonArray; over Dictionary.Keys(); and over a retrofitted JsonObject.Keys()/Values(). |
Arrays
| Test |
What it verifies |
ArrayNativeMirrorTests |
Native array semantics: pre-initialized defaults, 1-based indexing, ArrayLen (with dimension), element read/write, expression indexes, for-loop fill, compound element assignment, Clear, CompressArray, both CopyArray overloads (copied count must match the destination length), and by-value vs var parameter passing. Native-mirrored. |
ArrayScriptTests |
Arrays in scripts: defaults, ArrayLen, indexing and fill, compound assignment, sized/typed elements (Code elements uppercase at store), Clear, CompressArray, CopyArray, nested index expressions, elements as arguments; plus the compile/runtime diagnostics — out-of-bounds, a := b rejected, foreach over an array rejected, indexing a scalar, wrong index type, and var/length/element-type/CopyArray-length mismatches. |