mug 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,4 +15,14 @@ class Test_self < Test::Unit::TestCase
15
15
  assert_equal( 6, 2.itself{|i| i*3 } )
16
16
  assert_equal( {1=>[1,1], 2=>[2,2], 3=>[3]}, [1,1,2,2,3].group_by(&:itself) )
17
17
  end
18
+ def test_revapply
19
+ p = proc {|*args| args }
20
+ assert_equal( [1], 1.revapply(&p) )
21
+ assert_equal( [1,2,3], 1.revapply(2,3,&p) )
22
+ if RUBY_VERSION.to_i >= 2
23
+ assert_equal( 3, 1.revapply(2,3).size )
24
+ else
25
+ assert_equal( [1,2,3], 1.revapply(2,3).first )
26
+ end
27
+ end
18
28
  end
@@ -1,22 +1,22 @@
1
- require 'test/unit'
2
- require 'bigdecimal'
3
- require 'bigdecimal/math'
4
-
5
- $VERBOSE = true
6
- require_relative '../lib/mug/tau'
7
- class Test_tau < Test::Unit::TestCase
8
- def test_math_tau
9
- # 6.283185307179586..
10
- assert_equal(Math::TAU, Math::PI*2.0)
11
- end
12
-
13
- include BigMath
14
- def test_TAU
15
- assert_equal(TAU(1).round(1).to_s('F'), '6.3')
16
- assert_equal(TAU(100).truncate(100).to_s('F'), '6.2831853071795864769252867665590057683943387987502116419498891846156328125724179972560696506842341359')
17
- assert_raise(ArgumentError) { TAU(0) }
18
- assert_raise(ArgumentError) { TAU(-3) }
19
- assert_raise(ArgumentError) { TAU('barf') }
20
- end
21
- end
22
-
1
+ require 'test/unit'
2
+ require 'bigdecimal'
3
+ require 'bigdecimal/math'
4
+
5
+ $VERBOSE = true
6
+ require_relative '../lib/mug/tau'
7
+ class Test_tau < Test::Unit::TestCase
8
+ def test_math_tau
9
+ # 6.283185307179586..
10
+ assert_equal(Math::TAU, Math::PI*2.0)
11
+ end
12
+
13
+ include BigMath
14
+ def test_TAU
15
+ assert_equal(TAU(1).round(1).to_s('F'), '6.3')
16
+ assert_equal(TAU(100).truncate(100).to_s('F'), '6.2831853071795864769252867665590057683943387987502116419498891846156328125724179972560696506842341359')
17
+ assert_raise(ArgumentError) { TAU(0) }
18
+ assert_raise(ArgumentError) { TAU(-3) }
19
+ assert_raise(ArgumentError) { TAU('barf') }
20
+ end
21
+ end
22
+
@@ -1,16 +1,16 @@
1
- require 'test/unit'
2
-
3
- $VERBOSE = true
4
- $ruby_2_1 = RUBY_VERSION.to_f >= 2.1
5
- require_relative '../lib/mug/to_h'
6
- class Test_enum_to_h < Test::Unit::TestCase
7
- def test_enum_to_h
8
- assert_equal( {}, [].to_h )
9
- assert_equal( {1=>nil,2=>nil}, [1,2].to_h ) unless $ruby_2_1
10
- assert_equal( {1=>nil,2=>nil}, (1..2).to_h ) unless $ruby_2_1
11
- assert_equal( {1=>2,3=>4}, [[1,2],[3,4]].to_h )
12
- assert_equal( {1=>4}, [[1,2],[1,4]].to_h )
13
- assert_raise(ArgumentError) { [[1,2,3]].to_h }
14
- end
15
- end
16
-
1
+ require 'test/unit'
2
+
3
+ $VERBOSE = true
4
+ $ruby_2_1 = RUBY_VERSION.to_f >= 2.1
5
+ require_relative '../lib/mug/to_h'
6
+ class Test_enum_to_h < Test::Unit::TestCase
7
+ def test_enum_to_h
8
+ assert_equal( {}, [].to_h )
9
+ assert_equal( {1=>nil,2=>nil}, [1,2].to_h ) unless $ruby_2_1
10
+ assert_equal( {1=>nil,2=>nil}, (1..2).to_h ) unless $ruby_2_1
11
+ assert_equal( {1=>2,3=>4}, [[1,2],[3,4]].to_h )
12
+ assert_equal( {1=>4}, [[1,2],[1,4]].to_h )
13
+ assert_raise(ArgumentError) { [[1,2,3]].to_h }
14
+ end
15
+ end
16
+
@@ -1,56 +1,56 @@
1
- require 'test/unit'
2
- $VERBOSE = true
3
-
4
- class Foo
5
- def bar a, b
6
- (a||0) + (b||0)
7
- end
8
- end
9
-
10
- require_relative '../lib/mug/apply'
11
- class Test_self < Test::Unit::TestCase
12
- def test_apply_proc
13
- prc = proc{|a,b,*c| (a||0) + (b||0) + c.inject(0, &:+) }
14
- p1 = prc.apply(1)
15
- assert( p1.is_a? Proc )
16
- assert_equal( 3, p1.apply(2) )
17
- assert_equal( 3, prc.apply(1,2) )
18
- assert_equal( 15, prc.apply(1,2,3,4,5) )
19
- end
20
- def test_apply_lambda
21
- lmb = lambda{|a,b,c| (a||0) + (b||0) + (c||0) }
22
-
23
- l1 = lmb.apply(1)
24
- assert( l1.is_a? Proc )
25
-
26
- l2 = l1.apply(2)
27
- assert( l2.is_a? Proc )
28
-
29
- assert_equal( 6, l2.apply(3) )
30
- assert_equal( 6, l1.apply(2,3) )
31
-
32
- assert_raise( ArgumentError ){ l2.apply(3, 4) }
33
- assert_raise( ArgumentError ){ lmb.apply(1, 2, 3, 4) }
34
- end
35
- def test_apply_method
36
- m1 = 1.method :+
37
- assert_equal( 3, m1.apply(2) )
38
- assert_raise( ArgumentError ){ m1.apply(2,3) }
39
-
40
- m2 = Foo.new.method :bar
41
- l1 = m2.apply(1)
42
- assert( l1.is_a? Proc )
43
-
44
- assert_equal( 3, l1.apply(2) )
45
- assert_equal( 3, m2.apply(1,2) )
46
-
47
- assert_raise( ArgumentError ){ l1.apply(2, 3) }
48
- assert_raise( ArgumentError ){ m2.apply(1, 2, 3) }
49
- end
50
- def test_curry_method
51
- m1 = 1.method :+
52
- assert( m1.curry.is_a? Proc )
53
- assert( m1.curry(1).is_a? Proc )
54
- assert_raise( ArgumentError ){ m1.curry(2) }
55
- end
56
- end
1
+ require 'test/unit'
2
+ $VERBOSE = true
3
+
4
+ class Foo
5
+ def bar a, b
6
+ (a||0) + (b||0)
7
+ end
8
+ end
9
+
10
+ require_relative '../lib/mug/apply'
11
+ class Test_self < Test::Unit::TestCase
12
+ def test_apply_proc
13
+ prc = proc{|a,b,*c| (a||0) + (b||0) + c.inject(0, &:+) }
14
+ p1 = prc.apply(1)
15
+ assert( p1.is_a? Proc )
16
+ assert_equal( 3, p1.apply(2) )
17
+ assert_equal( 3, prc.apply(1,2) )
18
+ assert_equal( 15, prc.apply(1,2,3,4,5) )
19
+ end
20
+ def test_apply_lambda
21
+ lmb = lambda{|a,b,c| (a||0) + (b||0) + (c||0) }
22
+
23
+ l1 = lmb.apply(1)
24
+ assert( l1.is_a? Proc )
25
+
26
+ l2 = l1.apply(2)
27
+ assert( l2.is_a? Proc )
28
+
29
+ assert_equal( 6, l2.apply(3) )
30
+ assert_equal( 6, l1.apply(2,3) )
31
+
32
+ assert_raise( ArgumentError ){ l2.apply(3, 4) }
33
+ assert_raise( ArgumentError ){ lmb.apply(1, 2, 3, 4) }
34
+ end
35
+ def test_apply_method
36
+ m1 = 1.method :+
37
+ assert_equal( 3, m1.apply(2) )
38
+ assert_raise( ArgumentError ){ m1.apply(2,3) }
39
+
40
+ m2 = Foo.new.method :bar
41
+ l1 = m2.apply(1)
42
+ assert( l1.is_a? Proc )
43
+
44
+ assert_equal( 3, l1.apply(2) )
45
+ assert_equal( 3, m2.apply(1,2) )
46
+
47
+ assert_raise( ArgumentError ){ l1.apply(2, 3) }
48
+ assert_raise( ArgumentError ){ m2.apply(1, 2, 3) }
49
+ end
50
+ def test_curry_method
51
+ m1 = 1.method :+
52
+ assert( m1.curry.is_a? Proc )
53
+ assert( m1.curry(1).is_a? Proc )
54
+ assert_raise( ArgumentError ){ m1.curry(2) }
55
+ end
56
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mug
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Kerwin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-08 00:00:00.000000000 Z
11
+ date: 2014-09-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  == MUG: Matty's Ultimate Gem
@@ -22,26 +22,26 @@ executables: []
22
22
  extensions: []
23
23
  extra_rdoc_files: []
24
24
  files:
25
- - lib/mug.rb
26
25
  - lib/mug/and-or.rb
27
26
  - lib/mug/apply.rb
28
- - lib/mug/array.rb
29
27
  - lib/mug/array/extend.rb
28
+ - lib/mug/array.rb
30
29
  - lib/mug/bool.rb
31
30
  - lib/mug/fragile-method-chain.rb
32
- - lib/mug/hash.rb
33
31
  - lib/mug/hash/map.rb
34
32
  - lib/mug/hash/operations.rb
33
+ - lib/mug/hash.rb
35
34
  - lib/mug/hashmap.rb
36
35
  - lib/mug/hashop.rb
37
- - lib/mug/iterator.rb
38
36
  - lib/mug/iterator/for.rb
39
37
  - lib/mug/iterator/method.rb
38
+ - lib/mug/iterator.rb
40
39
  - lib/mug/iterator_c.rb
41
40
  - lib/mug/maybe.rb
42
41
  - lib/mug/self.rb
43
42
  - lib/mug/tau.rb
44
43
  - lib/mug/to_h.rb
44
+ - lib/mug.rb
45
45
  - test/test-and-or.rb
46
46
  - test/test-array-extend.rb
47
47
  - test/test-bool.rb
@@ -65,31 +65,32 @@ require_paths:
65
65
  - lib
66
66
  required_ruby_version: !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - ">="
68
+ - - '>='
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0'
71
71
  required_rubygems_version: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  requirements: []
77
77
  rubyforge_project:
78
- rubygems_version: 2.2.2
78
+ rubygems_version: 2.0.3
79
79
  signing_key:
80
80
  specification_version: 4
81
81
  summary: 'MUG: Matty''s Ultimate Gem'
82
82
  test_files:
83
- - test/test-tau.rb
84
- - test/test-self.rb
85
- - test/test-bool.rb
86
- - test/test_apply.rb
87
- - test/test-to_h.rb
83
+ - test/test-and-or.rb
88
84
  - test/test-array-extend.rb
85
+ - test/test-bool.rb
89
86
  - test/test-fragile-method-chain.rb
90
- - test/test-and-or.rb
91
- - test/test-iterator-method.rb
92
- - test/test-iterator-for.rb
93
- - test/test-maybe.rb
94
87
  - test/test-hashmap.rb
95
88
  - test/test-hashop.rb
89
+ - test/test-iterator-for.rb
90
+ - test/test-iterator-method.rb
91
+ - test/test-maybe.rb
92
+ - test/test-self.rb
93
+ - test/test-tau.rb
94
+ - test/test-to_h.rb
95
+ - test/test_apply.rb
96
+ has_rdoc: true