diff options
| author | Kai Stevenson <kai@kaistevenson.com> | 2025-11-09 12:34:02 -0800 |
|---|---|---|
| committer | Kai Stevenson <kai@kaistevenson.com> | 2025-11-09 12:34:02 -0800 |
| commit | 93992029bd349185d15de02e0f633e95c62695a9 (patch) | |
| tree | 3fef46b489750d622d9e803aad16cc90e8a95210 /tests/type-consistency/spec/tostring.ts | |
| parent | 8442ed67628e5d51e02b876d0f27479f9215bf0a (diff) | |
Diffstat (limited to 'tests/type-consistency/spec/tostring.ts')
| -rw-r--r-- | tests/type-consistency/spec/tostring.ts | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/type-consistency/spec/tostring.ts b/tests/type-consistency/spec/tostring.ts new file mode 100644 index 0000000..4fcb803 --- /dev/null +++ b/tests/type-consistency/spec/tostring.ts @@ -0,0 +1,41 @@ +import path from "path"; +import { createTestHarness } from "../harness"; + +export default createTestHarness({ + harnessName: "ToString", + generatedPath: path.join(__dirname, "..", "generated"), +}) + .createFunctionTest({ + name: "Passes through strings literally", + program: "fn(x, tostring(x))", + cases: [ + { input: "hello", output: "hello" }, + { input: "1", output: "1" }, + { input: "[1,2,3]", output: "[1,2,3]" }, + ], + }) + .createFunctionTest({ + name: "Is idempotent", + program: "fn(x, tostring(tostring(x)))", + cases: [ + { input: "hello", output: "hello" }, + { input: "1", output: "1" }, + { input: "[1,2,3]", output: "[1,2,3]" }, + ], + }) + .createFunctionTest({ + name: "Handles primitives", + program: "fn(x, tostring(x))", + cases: [ + { input: 5, output: "5" }, + { input: true, output: "true" }, + ], + }) + .createFunctionTest({ + name: "Handles arrays and nested arrays", + program: "fn(x, tostring(x))", + cases: [ + { input: [1, 2, 3], output: "[1, 2, 3]" }, + { input: [1, 2, [3, 4, 5]], output: "[1, 2, [3, 4, 5]]" }, + ], + }); |
