-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from spiltcoffee/raws
feat(grammar): capturing raws
- Loading branch information
Showing
30 changed files
with
1,096 additions
and
506 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.dfm eol=crlf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
201 changes: 92 additions & 109 deletions
201
.../@postdfm/ast/__test__/formObject.test.ts → ...ages/@postdfm/ast/__test__/object.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,109 +1,92 @@ | ||
import * as AST from "../src"; | ||
|
||
describe("creating FormObjects", () => { | ||
test("empty FormObject", () => { | ||
const node = new AST.FormObject( | ||
AST.ObjectKind.Inherited, | ||
"MyForm", | ||
"TMyForm" | ||
); | ||
|
||
expect(node.kind).toBe(AST.ObjectKind.Inherited); | ||
expect(node.name).toBe("MyForm"); | ||
expect(node.type).toBe("TMyForm"); | ||
expect(node.order).toBeUndefined(); | ||
expect(node.properties).toHaveLength(0); | ||
expect(node.children).toHaveLength(0); | ||
}); | ||
|
||
test("FormObject with order", () => { | ||
const node = new AST.FormObject( | ||
AST.ObjectKind.Inline, | ||
"MyForm", | ||
"TMyForm", | ||
0 | ||
); | ||
|
||
expect(node.kind).toBe(AST.ObjectKind.Inline); | ||
expect(node.name).toBe("MyForm"); | ||
expect(node.type).toBe("TMyForm"); | ||
expect(node.order).toBe(0); | ||
expect(node.properties).toHaveLength(0); | ||
expect(node.children).toHaveLength(0); | ||
}); | ||
|
||
test("FormObject with properties", () => { | ||
const propertyNode = new AST.Property( | ||
"Font.Name", | ||
new AST.StringValue("sans-serif") | ||
); | ||
|
||
const node = new AST.FormObject( | ||
AST.ObjectKind.Object, | ||
"MyForm", | ||
"TMyForm", | ||
undefined, | ||
[propertyNode] | ||
); | ||
|
||
expect(node.kind).toBe(AST.ObjectKind.Object); | ||
expect(node.name).toBe("MyForm"); | ||
expect(node.type).toBe("TMyForm"); | ||
expect(node.order).toBeUndefined(); | ||
expect(node.properties).toContainEqual(propertyNode); | ||
expect(node.children).toHaveLength(0); | ||
}); | ||
|
||
test("FormObject with children", () => { | ||
const childNode = new AST.FormObject( | ||
AST.ObjectKind.Object, | ||
"MyEdit", | ||
"TEdit" | ||
); | ||
|
||
const node = new AST.FormObject( | ||
AST.ObjectKind.Object, | ||
"MyForm", | ||
"TMyForm", | ||
undefined, | ||
undefined, | ||
[childNode] | ||
); | ||
|
||
expect(node.kind).toBe(AST.ObjectKind.Object); | ||
expect(node.name).toBe("MyForm"); | ||
expect(node.type).toBe("TMyForm"); | ||
expect(node.order).toBeUndefined(); | ||
expect(node.properties).toHaveLength(0); | ||
expect(node.children).toContainEqual(childNode); | ||
}); | ||
|
||
test("FormObject with a bit of everything", () => { | ||
const propertyNode = new AST.Property( | ||
"Font.Name", | ||
new AST.StringValue("sans-serif") | ||
); | ||
|
||
const childNode = new AST.FormObject( | ||
AST.ObjectKind.Object, | ||
"MyEdit", | ||
"TEdit" | ||
); | ||
|
||
const node = new AST.FormObject( | ||
AST.ObjectKind.Object, | ||
"MyForm", | ||
"TMyForm", | ||
0, | ||
[propertyNode], | ||
[childNode] | ||
); | ||
|
||
expect(node.kind).toBe(AST.ObjectKind.Object); | ||
expect(node.name).toBe("MyForm"); | ||
expect(node.type).toBe("TMyForm"); | ||
expect(node.order).toBe(0); | ||
expect(node.properties).toContainEqual(propertyNode); | ||
expect(node.children).toContainEqual(childNode); | ||
}); | ||
}); | ||
import * as AST from "../src"; | ||
|
||
describe("creating FormObjects", () => { | ||
test("empty FormObject", () => { | ||
const node = new AST.DObject(AST.ObjectKind.Inherited, "MyForm", "TMyForm"); | ||
|
||
expect(node.kind).toBe(AST.ObjectKind.Inherited); | ||
expect(node.name).toBe("MyForm"); | ||
expect(node.type).toBe("TMyForm"); | ||
expect(node.order).toBeUndefined(); | ||
expect(node.properties).toHaveLength(0); | ||
expect(node.children).toHaveLength(0); | ||
}); | ||
|
||
test("FormObject with order", () => { | ||
const node = new AST.DObject(AST.ObjectKind.Inline, "MyForm", "TMyForm", 0); | ||
|
||
expect(node.kind).toBe(AST.ObjectKind.Inline); | ||
expect(node.name).toBe("MyForm"); | ||
expect(node.type).toBe("TMyForm"); | ||
expect(node.order).toBe(0); | ||
expect(node.properties).toHaveLength(0); | ||
expect(node.children).toHaveLength(0); | ||
}); | ||
|
||
test("FormObject with properties", () => { | ||
const propertyNode = new AST.Property( | ||
"Font.Name", | ||
new AST.StringValue("sans-serif") | ||
); | ||
|
||
const node = new AST.DObject( | ||
AST.ObjectKind.Object, | ||
"MyForm", | ||
"TMyForm", | ||
undefined, | ||
[propertyNode] | ||
); | ||
|
||
expect(node.kind).toBe(AST.ObjectKind.Object); | ||
expect(node.name).toBe("MyForm"); | ||
expect(node.type).toBe("TMyForm"); | ||
expect(node.order).toBeUndefined(); | ||
expect(node.properties).toContainEqual(propertyNode); | ||
expect(node.children).toHaveLength(0); | ||
}); | ||
|
||
test("FormObject with children", () => { | ||
const childNode = new AST.DObject(AST.ObjectKind.Object, "MyEdit", "TEdit"); | ||
|
||
const node = new AST.DObject( | ||
AST.ObjectKind.Object, | ||
"MyForm", | ||
"TMyForm", | ||
undefined, | ||
undefined, | ||
[childNode] | ||
); | ||
|
||
expect(node.kind).toBe(AST.ObjectKind.Object); | ||
expect(node.name).toBe("MyForm"); | ||
expect(node.type).toBe("TMyForm"); | ||
expect(node.order).toBeUndefined(); | ||
expect(node.properties).toHaveLength(0); | ||
expect(node.children).toContainEqual(childNode); | ||
}); | ||
|
||
test("FormObject with a bit of everything", () => { | ||
const propertyNode = new AST.Property( | ||
"Font.Name", | ||
new AST.StringValue("sans-serif") | ||
); | ||
|
||
const childNode = new AST.DObject(AST.ObjectKind.Object, "MyEdit", "TEdit"); | ||
|
||
const node = new AST.DObject( | ||
AST.ObjectKind.Object, | ||
"MyForm", | ||
"TMyForm", | ||
0, | ||
[propertyNode], | ||
[childNode] | ||
); | ||
|
||
expect(node.kind).toBe(AST.ObjectKind.Object); | ||
expect(node.name).toBe("MyForm"); | ||
expect(node.type).toBe("TMyForm"); | ||
expect(node.order).toBe(0); | ||
expect(node.properties).toContainEqual(propertyNode); | ||
expect(node.children).toContainEqual(childNode); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as AST from "../src"; | ||
|
||
describe("creating FormObjects", () => { | ||
test("empty Root", () => { | ||
const node = new AST.Root(); | ||
|
||
expect(node.child).toBeUndefined(); | ||
}); | ||
|
||
test("empty FormObject", () => { | ||
const objectNode = new AST.DObject( | ||
AST.ObjectKind.Inherited, | ||
"MyForm", | ||
"TMyForm" | ||
); | ||
|
||
const node = new AST.Root(objectNode); | ||
|
||
expect(node.child).toBeDefined(); | ||
if (node.child) { | ||
expect(node.child.kind).toBe(AST.ObjectKind.Inherited); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.