Adds JSON with comments and trailing comma tests

This commit is contained in:
Tingan Ho 2015-07-27 19:52:25 +08:00
parent 5bb2e2f584
commit 684acffd19

View File

@ -0,0 +1,72 @@
/// <reference path="..\..\..\src\harness\harness.ts" />
/// <reference path="..\..\..\src\compiler\commandLineParser.ts" />
module ts {
describe("JSON with comments and trailing commas", () => {
it("should parse JSON with single line comments @jsonWithCommentsAndTrailingCommas", () => {
let json =
`{
"a": {
// comment
"b": true
}
}`;
expect(parseConfigFileText("file.ts", json).config).to.be.deep.equal({
a: { b: true }
});
});
it("should parse JSON with multiline line comments @jsonWithCommentsAndTrailingCommas", () => {
let json =
`{
"a": {
/*
* comment
*/
"b": true
}
}`;
expect(parseConfigFileText("file.ts", json).config).to.be.deep.equal({
a: { b: true }
});
});
it("should parse JSON with trailing commas in an object @jsonWithCommentsAndTrailingCommas", () => {
let json =
`{
"a": {
"b": true,
}
}`;
expect(parseConfigFileText("file.ts", json).config).to.be.deep.equal({
a: { b: true }
});
});
it("should parse JSON with trailing commas in an array @jsonWithCommentsAndTrailingCommas", () => {
let json =
`{
"a": [
"b",
]
}`;
expect(parseConfigFileText("file.ts", json).config).to.be.deep.equal({
a: [ "b" ]
});
});
it("should parse JSON with escape characters @jsonWithCommentsAndTrailingCommas", () => {
let json =
`{
"a": [
"b\\\"\\\\",
]
}`;
expect(parseConfigFileText("file.ts", json).config).to.be.deep.equal({
a: [ "b\"\\" ]
});
});
});
}