mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 20:14:01 -06:00
Adds JSON with comments and trailing comma tests
This commit is contained in:
parent
5bb2e2f584
commit
684acffd19
72
tests/cases/unittests/jsonWithCommentsAndTrailingCommas.ts
Normal file
72
tests/cases/unittests/jsonWithCommentsAndTrailingCommas.ts
Normal 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\"\\" ]
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user