fix(variable): Prevent crash on unknown index in array

This commit is contained in:
Kyle Fuller
2016-10-13 13:11:02 +01:00
parent 72f3cb579a
commit 1e3afc0dd5
3 changed files with 29 additions and 1 deletions

View File

@@ -52,6 +52,20 @@ func testVariable() {
let variable = Variable("contacts.0")
let result = try variable.resolve(context) as? String
try expect(result) == "Katie"
let variable1 = Variable("contacts.1")
let result1 = try variable1.resolve(context) as? String
try expect(result1) == "Carlton"
}
$0.it("can resolve an item from an array via unknown index") {
let variable = Variable("contacts.5")
let result = try variable.resolve(context) as? String
try expect(result).to.beNil()
let variable1 = Variable("contacts.-5")
let result1 = try variable1.resolve(context) as? String
try expect(result1).to.beNil()
}
$0.it("can resolve the first item from an array") {