Skip to content

Commit

Permalink
Add lexer test for escape sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
djbe committed Sep 23, 2018
1 parent d525a1a commit 0bfe195
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Tests/StencilTests/LexerSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,18 @@ class LexerTests: XCTestCase {
}
}
}

$0.it("can tokenize escape sequences") {
let templateString = "class Some {{ '{' }}{% if true %}{{ stuff }}{% endif %}"
let lexer = Lexer(templateString: templateString)
let tokens = lexer.tokenize()

try expect(tokens.count) == 5
try expect(tokens[0]) == Token.text(value: "class Some ", at: SourceMap(location: lexer.rangeLocation(templateString.range(of: "class Some ")!)))
try expect(tokens[1]) == Token.variable(value: "'{'", at: SourceMap(location: lexer.rangeLocation(templateString.range(of: "'{'")!)))
try expect(tokens[2]) == Token.block(value: "if true", at: SourceMap(location: lexer.rangeLocation(templateString.range(of: "if true")!)))
try expect(tokens[3]) == Token.variable(value: "stuff", at: SourceMap(location: lexer.rangeLocation(templateString.range(of: "stuff")!)))
try expect(tokens[4]) == Token.block(value: "endif", at: SourceMap(location: lexer.rangeLocation(templateString.range(of: "endif")!)))
}
}
}

0 comments on commit 0bfe195

Please sign in to comment.