Validation and testing
After generating JSON
- Parse it as JSON (your tools). If it fails, fix the file — do not patch ReScripted.
- Mentally (or with a script) confirm every key from
language_template.jsonstill exists at the same path and type. nameis real.extensionsis like[".foo"], not[".<EXTENSION>"].customonly holds extra kinds, not a second schema.builtins.functionsmatches what you willbind.
You may Language::compile the text in a tiny C++ program. If that throws, the JSON is unusable.
After embedding
The user’s program must compile. Missing embed::symbol means the generated header was not on the include path.
After writing scripts
Minimum host test:
engine.add_language(Language::compile(json));
try {
auto id = engine.load(example_source, "t", lang_name);
engine.run(id);
engine.unload(id);
} catch (const rescripted::Error& e) {
// fail the test with e.what()
}
Cover:
- A literal and
let - A
fn/ custom kind andcall - An
ifand awhileorfor - One host
bind unloadthengetis null for that function- A deliberate syntax error →
ParseError 1/0→RuntimeError
ReScripted’s own tests live in tests/runtime_test.cpp in the library repo. Do not add the user’s language tests there.
Schema drift
If compile succeeds but the script “ignores” a feature (classes, imports), that is expected — see implemented-schema.md. Do not “fix” it by deleting template keys.
Format
Pretty-print JSON with 2-space indent. No trailing comments (not JSON). No NaN. Use null where the template uses null.