Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Add specs
Browse files Browse the repository at this point in the history
  • Loading branch information
Winston Liu authored and Winston Liu committed Mar 25, 2019
1 parent 8a38a1c commit e4db094
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion spec/toml-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,40 @@ describe "TOML grammar", ->
{tokens} = grammar.tokenizeLine("foo = #{float}")
expect(tokens[4]).toEqual value: float, scopes: ["source.toml", "constant.numeric.toml"]

it "tokenizes dates", ->
it "tokenizes offset date-times", ->
{tokens} = grammar.tokenizeLine("foo = 1979-05-27T07:32:00Z")
expect(tokens[4]).toEqual value: "1979-05-27", scopes: ["source.toml", "constant.numeric.date.toml"]
expect(tokens[5]).toEqual value: "T", scopes: ["source.toml", "constant.numeric.date.toml", "keyword.other.time.toml"]
expect(tokens[6]).toEqual value: "07:32:00", scopes: ["source.toml", "constant.numeric.date.toml"]
expect(tokens[7]).toEqual value: "Z", scopes: ["source.toml", "constant.numeric.date.toml", "keyword.other.offset.toml"]

{tokens} = grammar.tokenizeLine("foo = 1979-05-27 07:32:00Z")
expect(tokens[4]).toEqual value: "1979-05-27", scopes: ["source.toml", "constant.numeric.date.toml"]
expect(tokens[5]).toEqual value: " ", scopes: ["source.toml", "constant.numeric.date.toml", "keyword.other.time.toml"]
expect(tokens[6]).toEqual value: "07:32:00", scopes: ["source.toml", "constant.numeric.date.toml"]
expect(tokens[7]).toEqual value: "Z", scopes: ["source.toml", "constant.numeric.date.toml", "keyword.other.offset.toml"]

{tokens} = grammar.tokenizeLine("foo = 1979-05-27T00:32:00.999999-07:00")
expect(tokens[4]).toEqual value: "1979-05-27", scopes: ["source.toml", "constant.numeric.date.toml"]
expect(tokens[5]).toEqual value: "T", scopes: ["source.toml", "constant.numeric.date.toml", "keyword.other.time.toml"]
expect(tokens[6]).toEqual value: "00:32:00.999999", scopes: ["source.toml", "constant.numeric.date.toml"]
expect(tokens[7]).toEqual value: "-", scopes: ["source.toml", "constant.numeric.date.toml", "keyword.other.offset.toml"]
expect(tokens[8]).toEqual value: "07:00", scopes: ["source.toml", "constant.numeric.date.toml"]

it "tokenizes local date-times", ->
{tokens} = grammar.tokenizeLine("foo = 1979-05-27T00:32:00.999999")
expect(tokens[4]).toEqual value: "1979-05-27", scopes: ["source.toml", "constant.numeric.date.toml"]
expect(tokens[5]).toEqual value: "T", scopes: ["source.toml", "constant.numeric.date.toml", "keyword.other.time.toml"]
expect(tokens[6]).toEqual value: "00:32:00.999999", scopes: ["source.toml", "constant.numeric.date.toml"]

it "tokenizes local dates", ->
{tokens} = grammar.tokenizeLine("foo = 1979-05-27")
expect(tokens[4]).toEqual value: "1979-05-27", scopes: ["source.toml", "constant.numeric.date.toml"]

it "tokenizes local times", ->
{tokens} = grammar.tokenizeLine("foo = 00:32:00.999999")
expect(tokens[4]).toEqual value: "00:32:00.999999", scopes: ["source.toml", "constant.numeric.date.toml"]

it "tokenizes tables", ->
{tokens} = grammar.tokenizeLine("[table]")
expect(tokens[0]).toEqual value: "[", scopes: ["source.toml", "entity.name.section.table.toml", "punctuation.definition.table.begin.toml"]
Expand Down

0 comments on commit e4db094

Please sign in to comment.