@weborigami/language 0.0.41 → 0.0.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,66 +0,0 @@
1
- import assert from "node:assert";
2
- import { describe, test } from "node:test";
3
- import format from "../../src/runtime/format.js";
4
- import * as ops from "../../src/runtime/ops.js";
5
-
6
- describe("Origami language code formatter", () => {
7
- test("assignment", () => {
8
- const code = [ops.assign, "foo", [ops.scope, "bar"]];
9
- assert.equal(format(code), "foo = bar");
10
- });
11
-
12
- test("scope reference", () => {
13
- const code = [ops.scope, "foo"];
14
- assert.equal(format(code), "foo");
15
- });
16
-
17
- test("implicit function call", () => {
18
- const code = [ops.scope, "foo"];
19
- assert.equal(format(code, true), "foo()");
20
- });
21
-
22
- test("function call", () => {
23
- const code = [[ops.scope, "foo"], undefined];
24
- assert.equal(format(code, true), "foo()");
25
- });
26
-
27
- test("tree traversal with string args", () => {
28
- const code = [[ops.scope, "a"], "b", "c"];
29
- assert.equal(format(code), "a/b/c");
30
- });
31
-
32
- test("tree traversal with numeric and string args", () => {
33
- const code = [ops.scope, "fn", "x", 1, 2];
34
- assert.equal(format(code), "fn('x', 1, 2)");
35
- });
36
-
37
- test("tree traversal with function arg and string arg", () => {
38
- const code = [ops.scope, "fn", [ops.scope, "foo"], "bar"];
39
- assert.equal(format(code), "fn(foo, 'bar')");
40
- });
41
-
42
- test("function composition", () => {
43
- const code = [[[ops.scope, "fn"], "a"], "b"];
44
- assert.equal(format(code), "(fn/a)/b");
45
- });
46
-
47
- test("lambda", () => {
48
- const code = [ops.lambda, null, [ops.scope, "message"]];
49
- assert.equal(format(code), "=message");
50
- });
51
-
52
- test("object", () => {
53
- const code = [ops.object, ["a", "Hello"], ["b", "Goodbye"]];
54
- assert.equal(format(code), "{ a: 'Hello', b: 'Goodbye' }");
55
- });
56
-
57
- test("template", () => {
58
- const code = [ops.concat, "Hello, ", [ops.scope, "name"], "."];
59
- assert.equal(format(code), "`Hello, {{name}}.`");
60
- });
61
-
62
- test("tree", () => {
63
- const code = [ops.tree, ["x", [[ops.scope, "fn"], undefined]]];
64
- assert.equal(format(code), "{ x = fn() }");
65
- });
66
- });