fuby 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +8 -0
- data/VERSION +1 -0
- data/fuby.gemspec +21 -0
- data/lib/fuby.rb +1 -0
- data/lib/fuby/abbreviation.rb +20 -0
- data/lib/fuby/alias_method.rb +13 -0
- data/lib/fuby/all.rb +11 -0
- data/lib/fuby/and.rb +9 -0
- data/lib/fuby/any.rb +11 -0
- data/lib/fuby/attributes.rb +17 -0
- data/lib/fuby/bind.rb +21 -0
- data/lib/fuby/class_attributes.rb +39 -0
- data/lib/fuby/deep.rb +1 -0
- data/lib/fuby/deep_each.rb +14 -0
- data/lib/fuby/define_instance_method.rb +18 -0
- data/lib/fuby/define_missing_method.rb +36 -0
- data/lib/fuby/define_object_method.rb +18 -0
- data/lib/fuby/define_tok.rb +11 -0
- data/lib/fuby/descendants.rb +15 -0
- data/lib/fuby/dimension.rb +23 -0
- data/lib/fuby/drop.rb +20 -0
- data/lib/fuby/drop_until.rb +18 -0
- data/lib/fuby/drop_while.rb +15 -0
- data/lib/fuby/each.rb +2 -0
- data/lib/fuby/each_with_index_or_key.rb +19 -0
- data/lib/fuby/eql.rb +1 -0
- data/lib/fuby/eql_componentwise.rb +13 -0
- data/lib/fuby/equivalence.rb +13 -0
- data/lib/fuby/eval.rb +54 -0
- data/lib/fuby/extend.rb +13 -0
- data/lib/fuby/format.rb +9 -0
- data/lib/fuby/include.rb +13 -0
- data/lib/fuby/index_or_key.rb +19 -0
- data/lib/fuby/instance_attributes.rb +39 -0
- data/lib/fuby/intercept.rb +27 -0
- data/lib/fuby/invert.rb +16 -0
- data/lib/fuby/longest_common.rb +16 -0
- data/lib/fuby/matches.rb +11 -0
- data/lib/fuby/matches_componentwise.rb +11 -0
- data/lib/fuby/matches_part_of.rb +16 -0
- data/lib/fuby/matches_prefix_of.rb +11 -0
- data/lib/fuby/matches_suffix_of.rb +13 -0
- data/lib/fuby/member.rb +11 -0
- data/lib/fuby/merge.rb +20 -0
- data/lib/fuby/merge_css.rb +32 -0
- data/lib/fuby/method_added_as.rb +1 -0
- data/lib/fuby/method_added_as_binary_operator.rb +16 -0
- data/lib/fuby/method_added_as_filter.rb +19 -0
- data/lib/fuby/new.rb +16 -0
- data/lib/fuby/not.rb +25 -0
- data/lib/fuby/opposite.rb +29 -0
- data/lib/fuby/or.rb +9 -0
- data/lib/fuby/otherwise.rb +18 -0
- data/lib/fuby/part_of.rb +16 -0
- data/lib/fuby/plus.rb +10 -0
- data/lib/fuby/pop.rb +11 -0
- data/lib/fuby/pop_if.rb +15 -0
- data/lib/fuby/pop_options.rb +15 -0
- data/lib/fuby/pop_unless.rb +11 -0
- data/lib/fuby/pop_until.rb +11 -0
- data/lib/fuby/pop_while.rb +11 -0
- data/lib/fuby/prefix_of.rb +14 -0
- data/lib/fuby/prefixes.rb +11 -0
- data/lib/fuby/prepend.rb +11 -0
- data/lib/fuby/private.rb +11 -0
- data/lib/fuby/protected.rb +11 -0
- data/lib/fuby/public.rb +11 -0
- data/lib/fuby/push.rb +1 -0
- data/lib/fuby/push_options.rb +9 -0
- data/lib/fuby/random.rb +31 -0
- data/lib/fuby/self_and_descendants.rb +15 -0
- data/lib/fuby/shift.rb +11 -0
- data/lib/fuby/shift_if.rb +12 -0
- data/lib/fuby/shift_options.rb +11 -0
- data/lib/fuby/shift_unless.rb +12 -0
- data/lib/fuby/shift_until.rb +12 -0
- data/lib/fuby/shift_while.rb +16 -0
- data/lib/fuby/splat.rb +11 -0
- data/lib/fuby/strip.rb +24 -0
- data/lib/fuby/subclass.rb +22 -0
- data/lib/fuby/submodule.rb +22 -0
- data/lib/fuby/suffix_of.rb +19 -0
- data/lib/fuby/suffixes.rb +11 -0
- data/lib/fuby/take.rb +20 -0
- data/lib/fuby/take_until.rb +17 -0
- data/lib/fuby/take_while.rb +14 -0
- data/lib/fuby/tap.rb +28 -0
- data/lib/fuby/to.rb +1 -0
- data/lib/fuby/to_boolean.rb +32 -0
- data/lib/fuby/to_camel_case.rb +32 -0
- data/lib/fuby/to_case.rb +1 -0
- data/lib/fuby/to_components.rb +33 -0
- data/lib/fuby/to_dash_case.rb +28 -0
- data/lib/fuby/to_hash.rb +25 -0
- data/lib/fuby/to_pred.rb +7 -0
- data/lib/fuby/to_proc.rb +45 -0
- data/lib/fuby/to_regexp.rb +38 -0
- data/lib/fuby/to_snake_case.rb +28 -0
- data/lib/fuby/to_tok.rb +27 -0
- data/lib/fuby/tok.rb +2 -0
- data/lib/fuby/tok_arity.rb +18 -0
- data/lib/fuby/tok_direction.rb +16 -0
- data/lib/fuby/tok_parity.rb +11 -0
- data/lib/fuby/tok_side.rb +11 -0
- data/lib/fuby/try.rb +73 -0
- data/lib/fuby/try_each.rb +25 -0
- data/lib/fuby/try_eval.rb +19 -0
- data/lib/fuby/try_exec.rb +15 -0
- data/lib/fuby/unabbreviation.rb +17 -0
- data/lib/fuby/unshift.rb +1 -0
- data/lib/fuby/unshift_options.rb +11 -0
- data/lib/fuby/uuid.rb +28 -0
- data/test/fuby/abbreviation.rb +25 -0
- data/test/fuby/alias_method.rb +29 -0
- data/test/fuby/all.rb +15 -0
- data/test/fuby/and.rb +14 -0
- data/test/fuby/any.rb +15 -0
- data/test/fuby/attributes.rb +0 -0
- data/test/fuby/bind.rb +17 -0
- data/test/fuby/class_attributes.rb +0 -0
- data/test/fuby/deep.rb +0 -0
- data/test/fuby/deep_each.rb +0 -0
- data/test/fuby/define_missing_method.rb +33 -0
- data/test/fuby/define_tok.rb +0 -0
- data/test/fuby/descendants.rb +0 -0
- data/test/fuby/dimension.rb +0 -0
- data/test/fuby/drop.rb +28 -0
- data/test/fuby/drop_until.rb +26 -0
- data/test/fuby/drop_while.rb +26 -0
- data/test/fuby/each.rb +0 -0
- data/test/fuby/each_with_index_or_key.rb +22 -0
- data/test/fuby/eql.rb +0 -0
- data/test/fuby/eql_componentwise.rb +0 -0
- data/test/fuby/equivalence.rb +0 -0
- data/test/fuby/eval.rb +0 -0
- data/test/fuby/extend.rb +20 -0
- data/test/fuby/format.rb +0 -0
- data/test/fuby/include.rb +20 -0
- data/test/fuby/index_or_key.rb +0 -0
- data/test/fuby/instance_attributes.rb +0 -0
- data/test/fuby/intercept.rb +16 -0
- data/test/fuby/invert.rb +0 -0
- data/test/fuby/longest_common.rb +0 -0
- data/test/fuby/matches.rb +0 -0
- data/test/fuby/matches_componentwise.rb +0 -0
- data/test/fuby/matches_prefix_of.rb +0 -0
- data/test/fuby/matches_suffix_of.rb +0 -0
- data/test/fuby/member.rb +0 -0
- data/test/fuby/merge.rb +0 -0
- data/test/fuby/merge_css.rb +0 -0
- data/test/fuby/method_added_as.rb +0 -0
- data/test/fuby/method_added_as_binary_operator.rb +20 -0
- data/test/fuby/method_added_as_filter.rb +28 -0
- data/test/fuby/new.rb +3 -0
- data/test/fuby/not.rb +0 -0
- data/test/fuby/opposite.rb +0 -0
- data/test/fuby/or.rb +19 -0
- data/test/fuby/otherwise.rb +30 -0
- data/test/fuby/part_of.rb +0 -0
- data/test/fuby/plus.rb +0 -0
- data/test/fuby/pop.rb +0 -0
- data/test/fuby/pop_if.rb +31 -0
- data/test/fuby/pop_options.rb +31 -0
- data/test/fuby/pop_unless.rb +0 -0
- data/test/fuby/pop_until.rb +0 -0
- data/test/fuby/pop_while.rb +0 -0
- data/test/fuby/prefix_of.rb +0 -0
- data/test/fuby/prefixes.rb +13 -0
- data/test/fuby/prepend.rb +34 -0
- data/test/fuby/private.rb +0 -0
- data/test/fuby/protected.rb +0 -0
- data/test/fuby/public.rb +0 -0
- data/test/fuby/push.rb +0 -0
- data/test/fuby/push_options.rb +32 -0
- data/test/fuby/random.rb +0 -0
- data/test/fuby/self_and_descendants.rb +0 -0
- data/test/fuby/shift.rb +0 -0
- data/test/fuby/shift_if.rb +0 -0
- data/test/fuby/shift_options.rb +0 -0
- data/test/fuby/shift_unless.rb +0 -0
- data/test/fuby/shift_until.rb +0 -0
- data/test/fuby/shift_while.rb +0 -0
- data/test/fuby/splat.rb +0 -0
- data/test/fuby/strip.rb +0 -0
- data/test/fuby/submodule.rb +15 -0
- data/test/fuby/suffix_of.rb +0 -0
- data/test/fuby/suffixes.rb +13 -0
- data/test/fuby/take.rb +0 -0
- data/test/fuby/take_until.rb +0 -0
- data/test/fuby/take_while.rb +0 -0
- data/test/fuby/tap.rb +58 -0
- data/test/fuby/to_boolean.rb +31 -0
- data/test/fuby/to_camel_case.rb +15 -0
- data/test/fuby/to_components.rb +0 -0
- data/test/fuby/to_dash_case.rb +15 -0
- data/test/fuby/to_hash.rb +23 -0
- data/test/fuby/to_pred.rb +25 -0
- data/test/fuby/to_proc.rb +56 -0
- data/test/fuby/to_regexp.rb +38 -0
- data/test/fuby/to_snake_case.rb +15 -0
- data/test/fuby/to_tok.rb +0 -0
- data/test/fuby/tok.rb +0 -0
- data/test/fuby/tok_arity.rb +0 -0
- data/test/fuby/tok_direction.rb +0 -0
- data/test/fuby/tok_parity.rb +0 -0
- data/test/fuby/tok_side.rb +0 -0
- data/test/fuby/try.rb +52 -0
- data/test/fuby/try_each.rb +30 -0
- data/test/fuby/try_eval.rb +34 -0
- data/test/fuby/try_exec.rb +0 -0
- data/test/fuby/unabbreviation.rb +25 -0
- data/test/fuby/unshift.rb +0 -0
- data/test/fuby/unshift_options.rb +0 -0
- data/test/fuby/uuid.rb +31 -0
- data/test/fuby/version.rb +0 -0
- metadata +369 -0
data/test/fuby/and.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'fuby/and'
|
2
|
+
|
3
|
+
using Fuby
|
4
|
+
|
5
|
+
describe Hash do
|
6
|
+
describe "& that" do
|
7
|
+
it "creates a new hash by intersecting `self` and `that`" do
|
8
|
+
|
9
|
+
({ a:1 } & { b:2 }).must_equal Hash.new
|
10
|
+
({ a:1, b:2 } & { b:2, c:3 }).must_equal b:2
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/test/fuby/any.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'fuby/any'
|
2
|
+
|
3
|
+
using Fuby
|
4
|
+
|
5
|
+
describe Enumerable do
|
6
|
+
describe "any?" do
|
7
|
+
it "the behaviour of `any?` is modified in order to allow object (as well as Proc) arguments" do
|
8
|
+
|
9
|
+
[1, 2, 3].any?.must_be_instance_of Method
|
10
|
+
[1, 2, 3].any?.call(String).must_equal false
|
11
|
+
[1, 2, 3].any?(Integer).must_equal true
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
File without changes
|
data/test/fuby/bind.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'fuby/bind'
|
2
|
+
|
3
|
+
using Fuby
|
4
|
+
|
5
|
+
describe Proc do
|
6
|
+
describe "bind receiver" do
|
7
|
+
it "binds self to the given receiver" do
|
8
|
+
|
9
|
+
foo = -> { self }
|
10
|
+
bar = {}
|
11
|
+
qux = foo.bind bar
|
12
|
+
qux.must_be_instance_of Method
|
13
|
+
qux.call.must_equal bar
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
File without changes
|
data/test/fuby/deep.rb
ADDED
File without changes
|
File without changes
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'fuby/define_missing_method'
|
2
|
+
|
3
|
+
using Fuby
|
4
|
+
|
5
|
+
describe Module do
|
6
|
+
describe "define_missing_method pattern, &block" do
|
7
|
+
it "defines a missing_method handler for keys matching the given pattern" do
|
8
|
+
|
9
|
+
class A
|
10
|
+
|
11
|
+
define_missing_method /any/ do
|
12
|
+
5
|
13
|
+
end
|
14
|
+
|
15
|
+
define_missing_method /all/ do
|
16
|
+
5
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
A.new.many.must_equal 5
|
22
|
+
A.new.respond_to?(:zany).must_equal true
|
23
|
+
A.new.respond_to?(:mall).must_equal true
|
24
|
+
|
25
|
+
end
|
26
|
+
it "prepends any matched anonymous groups" do
|
27
|
+
|
28
|
+
class A
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
data/test/fuby/drop.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'fuby/drop'
|
2
|
+
|
3
|
+
using Fuby
|
4
|
+
|
5
|
+
describe Array do
|
6
|
+
describe "drop number = 1" do
|
7
|
+
it "returns a new array dropping the initial number elements" do
|
8
|
+
|
9
|
+
xs = [1, 2, 3, :four]
|
10
|
+
|
11
|
+
xs.drop.must_equal [2, 3, :four]
|
12
|
+
xs.drop(2).must_equal [3, :four]
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
describe "drop! predicate = Proc.new" do
|
17
|
+
it "dropping the initial elements that don't match the given predicate, returning self" do
|
18
|
+
|
19
|
+
xs = [1, 2, 3, :four]
|
20
|
+
|
21
|
+
xs.drop!.must_equal xs
|
22
|
+
xs.must_equal [2, 3, :four]
|
23
|
+
xs.drop! 2
|
24
|
+
xs.must_equal [:four]
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# require 'fuby/drop_until'
|
2
|
+
|
3
|
+
# using Fuby
|
4
|
+
|
5
|
+
# describe Array do
|
6
|
+
# describe "drop_until predicate = Proc.new" do
|
7
|
+
# it "returns a new array dropping the initial elements that don't match the given predicate" do
|
8
|
+
|
9
|
+
# xs = [1, 2, 3, :four]
|
10
|
+
|
11
|
+
# xs.drop_until { false }.must_equal []
|
12
|
+
# xs.drop_until(Symbol).must_equal [:four]
|
13
|
+
|
14
|
+
# end
|
15
|
+
# end
|
16
|
+
# describe "drop_until! predicate = Proc.new" do
|
17
|
+
# it "dropping the initial elements that don't match the given predicate, returning self" do
|
18
|
+
|
19
|
+
# xs = [1, 2, 3, :four]
|
20
|
+
|
21
|
+
# xs.drop_until!(Symbol).must_equal xs
|
22
|
+
# xs.must_equal [:four]
|
23
|
+
|
24
|
+
# end
|
25
|
+
# end
|
26
|
+
# end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# require 'fuby/drop_while'
|
2
|
+
|
3
|
+
# using Fuby
|
4
|
+
|
5
|
+
# describe Array do
|
6
|
+
# describe "drop_while predicate = Proc.new" do
|
7
|
+
# it "returns a new array dropping the initial elements matching the given predicate" do
|
8
|
+
|
9
|
+
# xs = [1, 2, 3, :four]
|
10
|
+
|
11
|
+
# xs.drop_while { true }.must_equal []
|
12
|
+
# xs.drop_while(Integer).must_equal [:four]
|
13
|
+
|
14
|
+
# end
|
15
|
+
# end
|
16
|
+
# describe "drop_while! predicate = Proc.new" do
|
17
|
+
# it "dropping the initial elements matching the given predicate, returning self" do
|
18
|
+
|
19
|
+
# xs = [1, 2, 3, :four]
|
20
|
+
|
21
|
+
# xs.drop_while!(Integer).must_equal xs
|
22
|
+
# xs.must_equal [:four]
|
23
|
+
|
24
|
+
# end
|
25
|
+
# end
|
26
|
+
# end
|
data/test/fuby/each.rb
ADDED
File without changes
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'fuby/each_with_index_or_key'
|
2
|
+
|
3
|
+
using Fuby
|
4
|
+
|
5
|
+
describe Array do
|
6
|
+
describe "each_with_index_or_key &block" do
|
7
|
+
it "is equivalent to each_with_index" do
|
8
|
+
|
9
|
+
[1, 2, 3].each_with_index_or_key.to_a.must_equal [[1, 0], [2, 1], [3, 2]]
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
describe Hash do
|
15
|
+
describe "each_with_index_or_key &block" do
|
16
|
+
it "enumerates self with a block taking the element and key as arguments" do
|
17
|
+
|
18
|
+
{ a:1, b:2 }.each_with_index_or_key.to_a.must_equal [[1, :a], [2, :b]]
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/test/fuby/eql.rb
ADDED
File without changes
|
File without changes
|
File without changes
|
data/test/fuby/eval.rb
ADDED
File without changes
|
data/test/fuby/extend.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'fuby/extend'
|
2
|
+
|
3
|
+
using Fuby
|
4
|
+
|
5
|
+
describe Module do
|
6
|
+
describe "extend &block" do
|
7
|
+
it "creates and extends a module based on the given &block" do
|
8
|
+
|
9
|
+
o = Object.new
|
10
|
+
o.extend! do
|
11
|
+
|
12
|
+
def foo
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
o.must_respond_to :foo
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/test/fuby/format.rb
ADDED
File without changes
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'fuby/include'
|
2
|
+
|
3
|
+
using Fuby
|
4
|
+
|
5
|
+
describe Module do
|
6
|
+
describe "include &block" do
|
7
|
+
it "creates and includes a module based on the given &block" do
|
8
|
+
|
9
|
+
c = Class.new
|
10
|
+
c.include! do
|
11
|
+
|
12
|
+
def foo
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
c.new.must_respond_to :foo
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'fuby/intercept'
|
2
|
+
|
3
|
+
using Fuby
|
4
|
+
|
5
|
+
describe Module do
|
6
|
+
describe "intercept &block" do
|
7
|
+
it "creates a proxy of self, with method_missing defined from the given &block" do
|
8
|
+
|
9
|
+
object = {}
|
10
|
+
object.intercept { |key, *sig, &blk| self }.foo.must_equal object
|
11
|
+
object.intercept { |key, *sig, &blk| key }.foo.must_equal :foo
|
12
|
+
object.intercept { |key, *sig, &blk| sig }.foo(1, 2, 3).must_equal [1, 2, 3]
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/test/fuby/invert.rb
ADDED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/test/fuby/member.rb
ADDED
File without changes
|
data/test/fuby/merge.rb
ADDED
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'fuby/method_added_as_binary_operator'
|
2
|
+
|
3
|
+
using Fuby
|
4
|
+
|
5
|
+
describe Module do
|
6
|
+
describe "method_added_as_binary_operator *names" do
|
7
|
+
it "redefines the referenced methods as binary operators, allowing currying of the second argument" do
|
8
|
+
|
9
|
+
class Array
|
10
|
+
method_added_as_binary_operator :push
|
11
|
+
end
|
12
|
+
|
13
|
+
xs = [1, 2, 3]
|
14
|
+
xs.push.must_be_instance_of Method
|
15
|
+
xs.push.call 4
|
16
|
+
xs.must_equal [1, 2, 3, 4]
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'fuby/method_added_as_filter'
|
2
|
+
|
3
|
+
using Fuby
|
4
|
+
|
5
|
+
describe Module do
|
6
|
+
describe "method_added_as_filter *names" do
|
7
|
+
it "redefines the referenced methods as filter methods" do
|
8
|
+
|
9
|
+
m = Module.new do
|
10
|
+
|
11
|
+
def foo &pred
|
12
|
+
[1, 2, 3].select &pred
|
13
|
+
end
|
14
|
+
|
15
|
+
method_added_as_filter :foo
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
c = Class.new
|
20
|
+
c.send :include, m
|
21
|
+
c.new.must_respond_to :foo
|
22
|
+
|
23
|
+
c.new.foo { |i| i < 3 }.must_equal [1, 2]
|
24
|
+
c.new.foo(Integer).must_equal [1, 2, 3]
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/test/fuby/new.rb
ADDED
data/test/fuby/not.rb
ADDED
File without changes
|
File without changes
|
data/test/fuby/or.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'fuby/or'
|
2
|
+
|
3
|
+
using Fuby
|
4
|
+
|
5
|
+
describe Hash do
|
6
|
+
describe "| that" do
|
7
|
+
it "creates a new hash by merging `self` into `that`" do
|
8
|
+
|
9
|
+
({ a:1 } | { b:2 }).must_equal a:1, b:2
|
10
|
+
|
11
|
+
end
|
12
|
+
it "should preserve key order" do
|
13
|
+
|
14
|
+
({ a:1 } | { b:2 }).keys.first.must_equal :a
|
15
|
+
({ b:2 } | { a:1 }).keys.first.must_equal :b
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'fuby/otherwise'
|
2
|
+
|
3
|
+
using Fuby
|
4
|
+
|
5
|
+
describe Object do
|
6
|
+
describe 'otherwise(that, &block)' do
|
7
|
+
it "returns self" do
|
8
|
+
|
9
|
+
5.otherwise(6).must_be_same_as 5
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
describe NilClass do
|
16
|
+
describe 'otherwise(that)' do
|
17
|
+
it "returns that" do
|
18
|
+
|
19
|
+
nil.otherwise(5).must_be_same_as 5
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
describe 'otherwise{that}' do
|
24
|
+
it "returns that" do
|
25
|
+
|
26
|
+
nil.otherwise{5}.must_be_same_as 5
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
File without changes
|
data/test/fuby/plus.rb
ADDED
File without changes
|
data/test/fuby/pop.rb
ADDED
File without changes
|
data/test/fuby/pop_if.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'fuby/to_boolean'
|
2
|
+
|
3
|
+
using Fuby
|
4
|
+
|
5
|
+
describe Numeric do
|
6
|
+
describe "to_boolean" do
|
7
|
+
it "converts self to a boolean according to the common interpretation" do
|
8
|
+
|
9
|
+
0.to_boolean.must_equal false
|
10
|
+
1.to_boolean.must_equal true
|
11
|
+
+0.1.to_boolean.must_equal true
|
12
|
+
-0.1.to_boolean.must_equal false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe String do
|
18
|
+
describe "to_boolean" do
|
19
|
+
it "converts self to a boolean according to the common interpretation" do
|
20
|
+
|
21
|
+
"1".to_boolean.must_equal true
|
22
|
+
"t".to_boolean.must_equal true
|
23
|
+
"true".to_boolean.must_equal true
|
24
|
+
"TRUE".to_boolean.must_equal true
|
25
|
+
"yes".to_boolean.must_equal true
|
26
|
+
"y".to_boolean.must_equal true
|
27
|
+
"goo".to_boolean.must_equal false
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|