-
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 #66 from spiltcoffee/tests
fix(@postdfm/dfm2ast): emptry string ('') marked as unknown syntax
- Loading branch information
Showing
7 changed files
with
297 additions
and
205 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,4 @@ | ||
object Form1: TForm1 | ||
Left = 192 | ||
Font.Name = 'MS Sans Serif' | ||
Font.Style = [] |
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,11 @@ | ||
import * as fs from "fs"; | ||
import * as path from "path"; | ||
import * as dfm2ast from "../../src"; | ||
|
||
describe("dfm2ast", () => { | ||
test("broken DFM throws error", () => { | ||
const dfm = fs.readFileSync(path.join(__dirname, "form.dfm"), "ascii"); | ||
|
||
expect(() => dfm2ast.parse(dfm)).toThrowError("Unexpected End Of Input"); | ||
}); | ||
}); |
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,224 @@ | ||
{ | ||
"astType": "object", | ||
"kind": "object", | ||
"name": "Form1", | ||
"type": "TForm1", | ||
"properties": [ | ||
{ | ||
"astType": "property", | ||
"name": "Left", | ||
"value": { | ||
"astType": "integer", | ||
"value": "192" | ||
} | ||
}, | ||
{ | ||
"astType": "property", | ||
"name": "Font.Name", | ||
"value": { | ||
"astType": "string", | ||
"value": "MS Sans Serif" | ||
} | ||
}, | ||
{ | ||
"astType": "property", | ||
"name": "Font.Style", | ||
"value": { "astType": "qualifiedList", "values": [] } | ||
} | ||
], | ||
"children": [ | ||
{ | ||
"astType": "object", | ||
"kind": "object", | ||
"name": "Image1", | ||
"type": "TImage", | ||
"properties": [ | ||
{ | ||
"astType": "property", | ||
"name": "Picture.Data", | ||
"value": { | ||
"astType": "hexString", | ||
"value": "07544269746D617036550000424D365500000000000036000000280000005500000055000000010018000000000000550000C40E0000C40E0000000000000000" | ||
} | ||
}, | ||
{ | ||
"astType": "property", | ||
"name": "Picture.MoreData", | ||
"value": { "astType": "hexString", "value": "" } | ||
} | ||
], | ||
"children": [] | ||
}, | ||
{ | ||
"astType": "object", | ||
"kind": "inherited", | ||
"name": "ListBox1", | ||
"type": "TListBox", | ||
"order": "2", | ||
"properties": [ | ||
{ | ||
"astType": "property", | ||
"name": "Items.Strings", | ||
"value": { | ||
"astType": "stringList", | ||
"values": "this is string.\r\nand another one...and another one...now with apostrophe '\r\nhow fancy" | ||
} | ||
}, | ||
{ | ||
"astType": "property", | ||
"name": "Items.MoreStrings", | ||
"value": { "astType": "stringList", "values": [] } | ||
} | ||
], | ||
"children": [] | ||
}, | ||
{ | ||
"astType": "object", | ||
"kind": "object", | ||
"name": "DBGrid1", | ||
"type": "TDBGrid", | ||
"properties": [ | ||
{ | ||
"astType": "property", | ||
"name": "Options", | ||
"value": { | ||
"astType": "qualifiedList", | ||
"values": [ | ||
{ "astType": "qualified", "value": "dgTitles" }, | ||
{ "astType": "qualified", "value": "dgIndicator" }, | ||
{ "astType": "qualified", "value": "dgColumnResize" }, | ||
{ "astType": "qualified", "value": "dgColLines" }, | ||
{ "astType": "qualified", "value": "dgRowLines" }, | ||
{ "astType": "qualified", "value": "dgTabs" }, | ||
{ "astType": "qualified", "value": "dgRowSelect" }, | ||
{ | ||
"astType": "qualified", | ||
"value": "dgConfirmDelete" | ||
}, | ||
{ | ||
"astType": "qualified", | ||
"value": "dgCancelOnExit" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"astType": "property", | ||
"name": "MoreOptions", | ||
"value": { | ||
"astType": "qualifiedList", | ||
"values": [] | ||
} | ||
}, | ||
{ | ||
"astType": "property", | ||
"name": "Columns", | ||
"value": { | ||
"astType": "itemList", | ||
"values": [ | ||
{ | ||
"astType": "item", | ||
"properties": [ | ||
{ | ||
"astType": "property", | ||
"name": "Expanded", | ||
"value": { | ||
"astType": "boolean", | ||
"value": false | ||
} | ||
}, | ||
{ | ||
"astType": "property", | ||
"name": "Visible", | ||
"value": { "astType": "boolean", "value": true } | ||
} | ||
] | ||
}, | ||
{ | ||
"astType": "item", | ||
"properties": [ | ||
{ | ||
"astType": "property", | ||
"name": "Expanded", | ||
"value": { "astType": "boolean", "value": false } | ||
}, | ||
{ | ||
"astType": "property", | ||
"name": "Visible", | ||
"value": { "astType": "boolean", "value": true } | ||
} | ||
] | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"astType": "property", | ||
"name": "MoreColumns", | ||
"value": { "astType": "itemList", "values": [] } | ||
} | ||
], | ||
"children": [] | ||
}, | ||
{ | ||
"astType": "object", | ||
"kind": "inline", | ||
"name": "Edit1", | ||
"type": "TEdit", | ||
"properties": [ | ||
{ | ||
"astType": "property", | ||
"name": "MaxLength", | ||
"value": { "astType": "double", "value": "6e20" } | ||
}, | ||
{ | ||
"astType": "property", | ||
"name": "MinLength", | ||
"value": { "astType": "double", "value": "-20e1" } | ||
}, | ||
{ | ||
"astType": "property", | ||
"name": "SomeOtherLength", | ||
"value": { "astType": "double", "value": "45.333e20" } | ||
}, | ||
{ | ||
"astType": "property", | ||
"name": "Color", | ||
"value": { "astType": "integer", "value": "FF0000" } | ||
} | ||
], | ||
"children": [] | ||
}, | ||
{ | ||
"astType": "object", | ||
"kind": "object", | ||
"name": "SubForm", | ||
"type": "TForm2", | ||
"properties": [], | ||
"children": [ | ||
{ | ||
"astType": "object", | ||
"kind": "inline", | ||
"name": "SubEdit", | ||
"type": "TEdit", | ||
"properties": [ | ||
{ | ||
"astType": "property", | ||
"name": "Value", | ||
"value": { "astType": "string", "value": "" } | ||
} | ||
], | ||
"children": [] | ||
} | ||
] | ||
}, | ||
{ | ||
"astType": "object", | ||
"kind": "object", | ||
"name": "Nothing", | ||
"type": "TNothing", | ||
"properties": [], | ||
"children": [] | ||
} | ||
] | ||
} |
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
32 changes: 16 additions & 16 deletions
32
...s/@postdfm/dfm2ast/__test__/index.test.ts → ...dfm2ast/__test__/everything/index.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,16 +1,16 @@ | ||
import * as fs from "fs"; | ||
import * as path from "path"; | ||
import * as dfm2ast from "../src"; | ||
|
||
describe("dfm2ast", () => { | ||
test("converted AST matches expected AST", () => { | ||
const dfm = fs.readFileSync(path.join(__dirname, "sample.dfm"), "ascii"); | ||
|
||
const received = JSON.parse(JSON.stringify(dfm2ast.parse(dfm))); | ||
const expected = JSON.parse( | ||
fs.readFileSync(path.join(__dirname, "expected.json"), "utf8") | ||
); | ||
|
||
expect(received).toEqual(expected); | ||
}); | ||
}); | ||
import * as fs from "fs"; | ||
import * as path from "path"; | ||
import * as dfm2ast from "../../src"; | ||
|
||
describe("dfm2ast", () => { | ||
test("converted AST matches expected AST", () => { | ||
const dfm = fs.readFileSync(path.join(__dirname, "form.dfm"), "ascii"); | ||
|
||
const received = JSON.parse(JSON.stringify(dfm2ast.parse(dfm))); | ||
const expected = JSON.parse( | ||
fs.readFileSync(path.join(__dirname, "ast.json"), "utf8") | ||
); | ||
|
||
expect(received).toEqual(expected); | ||
}); | ||
}); |
Oops, something went wrong.