Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Yonaba/Moses.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorYonaba <roland.yonaba@gmail.com>2017-04-10 14:18:12 +0300
committerYonaba <roland.yonaba@gmail.com>2017-04-10 14:18:12 +0300
commit1ec911432cdaa1f9bad0a971ab1634d22e1decd3 (patch)
tree9cc6283af8d9ee4508705d03cafa3fe5f199a22a /spec
parent2881fa193c4d8de5c6918fb12cfe2944445577c4 (diff)
Added _.findIndex
Added _.findLastIndex Added _.bindAll Cross-referenced bind methods in documentation
Diffstat (limited to 'spec')
-rw-r--r--spec/array_spec.lua26
-rw-r--r--spec/func_spec.lua20
2 files changed, 45 insertions, 1 deletions
diff --git a/spec/array_spec.lua b/spec/array_spec.lua
index 5171478..7a324a4 100644
--- a/spec/array_spec.lua
+++ b/spec/array_spec.lua
@@ -154,7 +154,31 @@ context('Array functions specs', function()
end)
end)
-
+
+ context('findIndex', function()
+
+ test('returns the first index at which a predicate passes a truth test', function()
+ assert_equal(_.findIndex({1,2,3,4,5},function(__,v) return v%2==0 end),2)
+ end)
+
+ test('returns nil when nothing was found', function()
+ assert_nil(_.findIndex({1,2,3,4,5},function(_,v) return v>5 end))
+ end)
+
+ end)
+
+ context('findLastIndex', function()
+
+ test('returns the last index at which a predicate passes a truth test', function()
+ assert_equal(_.findLastIndex({1,2,3,4,5},function(_,v) return v%2==0 end),4)
+ end)
+
+ test('returns nil when nothing was found', function()
+ assert_nil(_.findLastIndex({1,2,3,4,5},function(_,v) return v>5 end))
+ end)
+
+ end)
+
context('addTop', function()
test('adds values at the top of an array', function()
diff --git a/spec/func_spec.lua b/spec/func_spec.lua
index 7a554db..3586e78 100644
--- a/spec/func_spec.lua
+++ b/spec/func_spec.lua
@@ -226,6 +226,26 @@ context('Utility functions specs', function()
end)
+ context('bindAll', function()
+
+ test('binds methods to object',function()
+ local window = {
+ setPos = function(w,x,y) w.x, w.y = x, y end,
+ setName = function(w,name) w.name = name end,
+ getName = function(w) return w.name end,
+ }
+ window = _.bindAll(window, 'setPos', 'setName', 'getName')
+ window.setPos(10,15)
+ window.setName('fooApp')
+
+ assert_equal(window.x, 10)
+ assert_equal(window.y, 15)
+ assert_equal(window.name, 'fooApp')
+ assert_equal(window.getName(), 'fooApp')
+ end)
+
+ end)
+
context('uniqueId', function()
test('returns an unique (for the current session) integer Id',function()