@graffiticode/parser 1.4.1 → 1.4.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graffiticode/parser",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
package/src/unparse.js CHANGED
@@ -100,7 +100,7 @@ function unparseNode(node, lexicon, indent = 0, options = {}) {
100
100
  if (opts.compact) {
101
101
  // Compact mode: inline list
102
102
  const items = node.elts.map(elt => unparseNode(elt, lexicon, indent, opts));
103
- return "[" + items.join(", ") + "]";
103
+ return "[" + items.join(" ") + "]";
104
104
  } else {
105
105
  // Pretty print with each element on a new line
106
106
  const innerIndent = indent + opts.indentSize;
@@ -181,9 +181,9 @@ function unparseNode(node, lexicon, indent = 0, options = {}) {
181
181
  const bodyStr = unparseNode(body, lexicon, indent, opts);
182
182
 
183
183
  if (paramStr) {
184
- return `\\${paramStr} . ${bodyStr}`;
184
+ return `<${paramStr}: ${bodyStr}>`;
185
185
  } else {
186
- return `\\. ${bodyStr}`;
186
+ return `<: ${bodyStr}>`;
187
187
  }
188
188
  }
189
189
  return "";
@@ -79,13 +79,13 @@ describe("unparse", () => {
79
79
  it("should unparse list with multiple elements", async () => {
80
80
  const source = "[1, 2, 3]..";
81
81
  const unparsed = await testRoundTrip(source);
82
- expect(unparsed).toBe("[1, 2, 3]..");
82
+ expect(unparsed).toBe("[1 2 3]..");
83
83
  });
84
84
 
85
85
  it("should unparse nested lists", async () => {
86
86
  const source = "[[1, 2], [3, 4]]..";
87
87
  const unparsed = await testRoundTrip(source);
88
- expect(unparsed).toBe("[[1, 2], [3, 4]]..");
88
+ expect(unparsed).toBe("[[1 2] [3 4]]..");
89
89
  });
90
90
 
91
91
  it("should unparse empty record", async () => {
@@ -207,6 +207,12 @@ describe("unparse", () => {
207
207
  const unparsed = await testRoundTrip(source);
208
208
  expect(unparsed).toBe("foo (bar 42)..");
209
209
  });
210
+
211
+ it("should unparse map with lambda and list", async () => {
212
+ const source = 'map (<x: add x 10>) [\n 1\n 2\n 3\n]..';
213
+ const unparsed = await testRoundTrip(source);
214
+ expect(unparsed).toBe("map (<x: add x 10>) [1 2 3]..");
215
+ });
210
216
  });
211
217
 
212
218
  describe("control flow", () => {
@@ -337,7 +343,7 @@ describe("unparse", () => {
337
343
  it("should support compact option", async () => {
338
344
  const source = "[1, 2, 3]..";
339
345
  const reformatted = await parser.reformat(0, source, basisLexicon, { compact: true });
340
- expect(reformatted).toBe("[1, 2, 3]..");
346
+ expect(reformatted).toBe("[1 2 3]..");
341
347
  });
342
348
 
343
349
  it("should support custom indent size", async () => {