store reference to token when parsing range variable

This commit is contained in:
Ilya Puchka
2018-08-12 22:25:25 +01:00
parent 3a4cd8aa27
commit 4f1a5b3e3d
3 changed files with 18 additions and 5 deletions

View File

@@ -292,7 +292,9 @@ func testVariable() {
}()
func makeVariable(_ token: String) throws -> RangeVariable? {
return try RangeVariable(token, parser: TokenParser(tokens: [], environment: context.environment))
let token = Token.variable(value: token, at: .unknown)
let parser = TokenParser(tokens: [token], environment: context.environment)
return try RangeVariable(token.contents, parser: parser, containedIn: token)
}
$0.it("can resolve closed range as array") {
@@ -321,11 +323,11 @@ func testVariable() {
}
$0.it("throws is left range value is missing") {
try expect(makeVariable("...1")).toThrow()
try expect(makeVariable("...1")).toThrow()
}
$0.it("throws is right range value is missing") {
try expect(makeVariable("1...")).toThrow()
try expect(makeVariable("1...")).toThrow()
}
}