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

chaining_spec.lua « spec - github.com/Yonaba/Moses.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fb11b90ce55bd2edd296fbb1d5ab6607e14b10da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
require 'luacov'
local M = require 'moses'

describe('Chaining specs', function()

   describe('chain', function()
  
    it('Chains a value',function()
      local v = M.chain({1,2,3,4})
        :filter(function(k) return k%2~=0 end)
        :max()
        :value()
      assert.equal(v, 3)
    end)
    
    it('M(value) is the same as M.chain(value)', function()
      local v = M({1,2,3,4})
        :filter(function(k) return k%2~=0 end)
        :max()
        :value()
      assert.equal(v, 3)    
    end)
    
  end) 
  
   describe('value', function()
  
    it('Unwraps a chained object',function()
      local t = {1,2,3}
      assert.equal(M.chain(t):value(), t)
      assert.equal(M(t):value(), t)
    end)
    
  end)   

end)