diff options
Diffstat (limited to 'spec/outputs')
| -rw-r--r-- | spec/outputs/test/in_expression_spec.lua | 47 |
1 files changed, 10 insertions, 37 deletions
diff --git a/spec/outputs/test/in_expression_spec.lua b/spec/outputs/test/in_expression_spec.lua index 83c542c..81506c5 100644 --- a/spec/outputs/test/in_expression_spec.lua +++ b/spec/outputs/test/in_expression_spec.lua | |||
| @@ -201,25 +201,7 @@ local _anon_func_21 = function(get_items) | |||
| 201 | end | 201 | end |
| 202 | return false | 202 | return false |
| 203 | end | 203 | end |
| 204 | local _anon_func_22 = function(items) | 204 | local _anon_func_22 = function(obj) |
| 205 | local _val_0 = nil | ||
| 206 | for _index_0 = 1, #items do | ||
| 207 | if items[_index_0] == _val_0 then | ||
| 208 | return true | ||
| 209 | end | ||
| 210 | end | ||
| 211 | return false | ||
| 212 | end | ||
| 213 | local _anon_func_23 = function(items) | ||
| 214 | local _val_0 = 1 | ||
| 215 | for _index_0 = 1, #items do | ||
| 216 | if items[_index_0] == _val_0 then | ||
| 217 | return true | ||
| 218 | end | ||
| 219 | end | ||
| 220 | return false | ||
| 221 | end | ||
| 222 | local _anon_func_24 = function(obj) | ||
| 223 | local _val_0 = "name" | 205 | local _val_0 = "name" |
| 224 | for _index_0 = 1, #obj do | 206 | for _index_0 = 1, #obj do |
| 225 | if obj[_index_0] == _val_0 then | 207 | if obj[_index_0] == _val_0 then |
| @@ -228,7 +210,7 @@ local _anon_func_24 = function(obj) | |||
| 228 | end | 210 | end |
| 229 | return false | 211 | return false |
| 230 | end | 212 | end |
| 231 | local _anon_func_25 = function(obj) | 213 | local _anon_func_23 = function(obj) |
| 232 | local _val_0 = "value" | 214 | local _val_0 = "value" |
| 233 | for _index_0 = 1, #obj do | 215 | for _index_0 = 1, #obj do |
| 234 | if obj[_index_0] == _val_0 then | 216 | if obj[_index_0] == _val_0 then |
| @@ -237,7 +219,7 @@ local _anon_func_25 = function(obj) | |||
| 237 | end | 219 | end |
| 238 | return false | 220 | return false |
| 239 | end | 221 | end |
| 240 | local _anon_func_26 = function(obj) | 222 | local _anon_func_24 = function(obj) |
| 241 | local _val_0 = "missing" | 223 | local _val_0 = "missing" |
| 242 | for _index_0 = 1, #obj do | 224 | for _index_0 = 1, #obj do |
| 243 | if obj[_index_0] == _val_0 then | 225 | if obj[_index_0] == _val_0 then |
| @@ -246,7 +228,7 @@ local _anon_func_26 = function(obj) | |||
| 246 | end | 228 | end |
| 247 | return false | 229 | return false |
| 248 | end | 230 | end |
| 249 | local _anon_func_27 = function(items) | 231 | local _anon_func_25 = function(items) |
| 250 | local _val_0 = 2 | 232 | local _val_0 = 2 |
| 251 | for _index_0 = 1, #items do | 233 | for _index_0 = 1, #items do |
| 252 | if items[_index_0] == _val_0 then | 234 | if items[_index_0] == _val_0 then |
| @@ -255,7 +237,7 @@ local _anon_func_27 = function(items) | |||
| 255 | end | 237 | end |
| 256 | return false | 238 | return false |
| 257 | end | 239 | end |
| 258 | local _anon_func_28 = function(allowed, item) | 240 | local _anon_func_26 = function(allowed, item) |
| 259 | for _index_0 = 1, #allowed do | 241 | for _index_0 = 1, #allowed do |
| 260 | if allowed[_index_0] == item then | 242 | if allowed[_index_0] == item then |
| 261 | return true | 243 | return true |
| @@ -411,23 +393,14 @@ return describe("in expression", function() | |||
| 411 | assert.is_true(_anon_func_20(get_items)) | 393 | assert.is_true(_anon_func_20(get_items)) |
| 412 | return assert.is_false(_anon_func_21(get_items)) | 394 | return assert.is_false(_anon_func_21(get_items)) |
| 413 | end) | 395 | end) |
| 414 | it("should handle nil in table", function() | ||
| 415 | local items = { | ||
| 416 | 1, | ||
| 417 | nil, | ||
| 418 | 3 | ||
| 419 | } | ||
| 420 | assert.is_true(_anon_func_22(items)) | ||
| 421 | return assert.is_true(_anon_func_23(items)) | ||
| 422 | end) | ||
| 423 | it("should work with string keys", function() | 396 | it("should work with string keys", function() |
| 424 | local obj = { | 397 | local obj = { |
| 425 | "name", | 398 | "name", |
| 426 | "value" | 399 | "value" |
| 427 | } | 400 | } |
| 428 | assert.is_true(_anon_func_24(obj)) | 401 | assert.is_true(_anon_func_22(obj)) |
| 429 | assert.is_true(_anon_func_25(obj)) | 402 | assert.is_true(_anon_func_23(obj)) |
| 430 | return assert.is_false(_anon_func_26(obj)) | 403 | return assert.is_false(_anon_func_24(obj)) |
| 431 | end) | 404 | end) |
| 432 | it("should support complex expressions", function() | 405 | it("should support complex expressions", function() |
| 433 | local items = { | 406 | local items = { |
| @@ -435,7 +408,7 @@ return describe("in expression", function() | |||
| 435 | 2, | 408 | 2, |
| 436 | 3 | 409 | 3 |
| 437 | } | 410 | } |
| 438 | local result = (_anon_func_27(items)) and "yes" or "no" | 411 | local result = (_anon_func_25(items)) and "yes" or "no" |
| 439 | return assert.same(result, "yes") | 412 | return assert.same(result, "yes") |
| 440 | end) | 413 | end) |
| 441 | return it("should work in comprehension", function() | 414 | return it("should work in comprehension", function() |
| @@ -456,7 +429,7 @@ return describe("in expression", function() | |||
| 456 | local _len_0 = 1 | 429 | local _len_0 = 1 |
| 457 | for _index_0 = 1, #source do | 430 | for _index_0 = 1, #source do |
| 458 | local item = source[_index_0] | 431 | local item = source[_index_0] |
| 459 | if (#allowed > 0 and _anon_func_28(allowed, item)) then | 432 | if (#allowed > 0 and _anon_func_26(allowed, item)) then |
| 460 | _accum_0[_len_0] = item | 433 | _accum_0[_len_0] = item |
| 461 | _len_0 = _len_0 + 1 | 434 | _len_0 = _len_0 + 1 |
| 462 | end | 435 | end |
