mustang 0.1.1 → 0.2.0
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.
- data/README.md +11 -1
- data/Rakefile +1 -1
- data/TODO.md +2 -1
- data/ext/v8/extconf.rb +3 -1
- data/ext/v8/v8_array.cpp +2 -0
- data/ext/v8/v8_context.cpp +32 -5
- data/ext/v8/v8_date.cpp +1 -0
- data/ext/v8/v8_external.cpp +1 -0
- data/ext/v8/v8_function.cpp +3 -0
- data/ext/v8/v8_integer.cpp +1 -0
- data/ext/v8/v8_macros.h +6 -0
- data/ext/v8/v8_main.cpp +3 -1
- data/ext/v8/v8_number.cpp +1 -0
- data/ext/v8/v8_object.cpp +2 -0
- data/ext/v8/v8_regexp.cpp +1 -0
- data/ext/v8/v8_string.cpp +1 -0
- data/ext/v8/v8_value.cpp +2 -0
- data/lib/mustang.rb +20 -27
- data/lib/mustang/context.rb +0 -26
- data/lib/{core_ext → mustang/core_ext}/class.rb +1 -1
- data/lib/{core_ext → mustang/core_ext}/object.rb +2 -4
- data/lib/{core_ext → mustang/core_ext}/symbol.rb +0 -0
- data/lib/{support → mustang/support}/delegated.rb +0 -0
- data/lib/mustang/v8/array.rb +21 -0
- data/lib/mustang/v8/context.rb +15 -0
- data/lib/mustang/v8/date.rb +20 -0
- data/lib/mustang/v8/error.rb +17 -0
- data/lib/mustang/v8/external.rb +16 -0
- data/lib/mustang/v8/function.rb +13 -0
- data/lib/mustang/v8/integer.rb +16 -0
- data/lib/mustang/v8/number.rb +16 -0
- data/lib/mustang/v8/object.rb +66 -0
- data/lib/mustang/v8/regexp.rb +23 -0
- data/lib/mustang/v8/string.rb +27 -0
- data/mustang.gemspec +1 -1
- data/spec/{core_ext → mustang/core_ext}/class_spec.rb +3 -3
- data/spec/{core_ext → mustang/core_ext}/object_spec.rb +3 -3
- data/spec/{core_ext → mustang/core_ext}/symbol_spec.rb +1 -1
- data/spec/{v8 → mustang/v8}/array_spec.rb +12 -5
- data/spec/{v8 → mustang/v8}/cast_spec.rb +10 -10
- data/spec/{v8 → mustang/v8}/context_spec.rb +52 -6
- data/spec/{v8 → mustang/v8}/data_spec.rb +4 -4
- data/spec/{v8 → mustang/v8}/date_spec.rb +12 -5
- data/spec/{v8 → mustang/v8}/empty_spec.rb +4 -4
- data/spec/{v8 → mustang/v8}/errors_spec.rb +9 -9
- data/spec/{v8 → mustang/v8}/external_spec.rb +14 -7
- data/spec/{v8 → mustang/v8}/function_spec.rb +20 -13
- data/spec/{v8 → mustang/v8}/integer_spec.rb +13 -6
- data/spec/{v8 → mustang/v8}/main_spec.rb +2 -2
- data/spec/{v8 → mustang/v8}/null_spec.rb +4 -4
- data/spec/{v8 → mustang/v8}/number_spec.rb +5 -5
- data/spec/{v8 → mustang/v8}/object_spec.rb +13 -6
- data/spec/mustang/v8/primitive_spec.rb +9 -0
- data/spec/{v8 → mustang/v8}/regexp_spec.rb +12 -5
- data/spec/{v8 → mustang/v8}/string_spec.rb +12 -5
- data/spec/{v8 → mustang/v8}/undefined_spec.rb +4 -4
- data/spec/mustang/v8/value_spec.rb +222 -0
- data/spec/spec_helper.rb +1 -1
- metadata +91 -62
- data/lib/v8/array.rb +0 -21
- data/lib/v8/context.rb +0 -13
- data/lib/v8/date.rb +0 -20
- data/lib/v8/error.rb +0 -15
- data/lib/v8/external.rb +0 -16
- data/lib/v8/function.rb +0 -11
- data/lib/v8/integer.rb +0 -16
- data/lib/v8/number.rb +0 -16
- data/lib/v8/object.rb +0 -66
- data/lib/v8/regexp.rb +0 -23
- data/lib/v8/string.rb +0 -27
- data/spec/v8/primitive_spec.rb +0 -9
- data/spec/v8/value_spec.rb +0 -215
@@ -1,18 +1,25 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
2
|
|
3
|
-
describe V8::Date do
|
4
|
-
subject { V8::Date }
|
3
|
+
describe Mustang::V8::Date do
|
4
|
+
subject { Mustang::V8::Date }
|
5
5
|
setup_context
|
6
6
|
|
7
7
|
before do
|
8
8
|
@now = Time.now
|
9
9
|
end
|
10
10
|
|
11
|
-
it "inherits V8::Value" do
|
12
|
-
subject.new(@now).should be_kind_of(V8::Value)
|
11
|
+
it "inherits Mustang::V8::Value" do
|
12
|
+
subject.new(@now).should be_kind_of(Mustang::V8::Value)
|
13
13
|
end
|
14
14
|
|
15
15
|
describe ".new" do
|
16
|
+
context "when no context entered" do
|
17
|
+
it "should raise error" do
|
18
|
+
Mustang::V8::Context.exit_all!
|
19
|
+
expect { subject.new(@now) }.to raise_error(RuntimeError, "can't create V8 object without entering into context")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
16
23
|
it "creates new v8 date based on passed value" do
|
17
24
|
subject.new(@now).to_i.should be_eql(@now.to_i)
|
18
25
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
2
|
|
3
|
-
describe V8::Empty do
|
3
|
+
describe Mustang::V8::Empty do
|
4
4
|
setup_context
|
5
5
|
|
6
|
-
it "is kind of V8::EmptyClass" do
|
7
|
-
subject.should be_kind_of(V8::EmptyClass)
|
6
|
+
it "is kind of Mustang::V8::EmptyClass" do
|
7
|
+
subject.should be_kind_of(Mustang::V8::EmptyClass)
|
8
8
|
end
|
9
9
|
|
10
10
|
describe "#null?" do
|
@@ -1,20 +1,20 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
2
|
|
3
3
|
describe "Exception handling" do
|
4
4
|
setup_context
|
5
5
|
|
6
6
|
it "returns v8 error object when JS code is broken" do
|
7
7
|
exc = cxt.eval("broken$code", "<eval>")
|
8
|
-
exc.should be_kind_of(V8::Error)
|
8
|
+
exc.should be_kind_of(Mustang::V8::Error)
|
9
9
|
exc.should be_error
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
describe V8::Error do
|
13
|
+
describe Mustang::V8::Error do
|
14
14
|
setup_context
|
15
15
|
|
16
|
-
it "inherits V8::Data" do
|
17
|
-
subject.should be_kind_of(V8::Data)
|
16
|
+
it "inherits Mustang::V8::Data" do
|
17
|
+
subject.should be_kind_of(Mustang::V8::Data)
|
18
18
|
end
|
19
19
|
|
20
20
|
it "#reference_error? returns false" do
|
@@ -101,7 +101,7 @@ describe "Returned error" do
|
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
|
-
describe V8::ReferenceError do
|
104
|
+
describe Mustang::V8::ReferenceError do
|
105
105
|
it "#reference_error? returns true" do
|
106
106
|
subject.should be_reference_error
|
107
107
|
end
|
@@ -111,7 +111,7 @@ describe V8::ReferenceError do
|
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
|
-
describe V8::SyntaxError do
|
114
|
+
describe Mustang::V8::SyntaxError do
|
115
115
|
it "#syntax_error? returns true" do
|
116
116
|
subject.should be_syntax_error
|
117
117
|
end
|
@@ -121,7 +121,7 @@ describe V8::SyntaxError do
|
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
|
-
describe V8::RangeError do
|
124
|
+
describe Mustang::V8::RangeError do
|
125
125
|
it "#range_error? returns true" do
|
126
126
|
subject.should be_range_error
|
127
127
|
end
|
@@ -131,7 +131,7 @@ describe V8::RangeError do
|
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
134
|
-
describe V8::TypeError do
|
134
|
+
describe Mustang::V8::TypeError do
|
135
135
|
it "#type_error? returns true" do
|
136
136
|
subject.should be_type_error
|
137
137
|
end
|
@@ -1,18 +1,25 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
2
|
require 'stringio'
|
3
3
|
|
4
|
-
describe V8::External do
|
5
|
-
subject { V8::External }
|
4
|
+
describe Mustang::V8::External do
|
5
|
+
subject { Mustang::V8::External }
|
6
6
|
setup_context
|
7
7
|
|
8
|
-
it "inherits V8::Value" do
|
9
|
-
subject.new(StringIO.new).should be_kind_of(V8::Value)
|
8
|
+
it "inherits Mustang::V8::Value" do
|
9
|
+
subject.new(StringIO.new).should be_kind_of(Mustang::V8::Value)
|
10
10
|
end
|
11
11
|
|
12
12
|
describe ".new" do
|
13
|
+
context "when no context entered" do
|
14
|
+
it "should raise error" do
|
15
|
+
Mustang::V8::Context.exit_all!
|
16
|
+
expect { Mustang::V8::External.new(StringIO.new) }.to raise_error(RuntimeError, "can't create V8 object without entering into context")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
13
20
|
it "creates new v8 external" do
|
14
21
|
obj = StringIO.new
|
15
|
-
subject.new(obj).should be_kind_of(V8::External)
|
22
|
+
subject.new(obj).should be_kind_of(Mustang::V8::External)
|
16
23
|
end
|
17
24
|
end
|
18
25
|
|
@@ -36,7 +43,7 @@ describe V8::External do
|
|
36
43
|
def bar; return 'bar'; end
|
37
44
|
end
|
38
45
|
|
39
|
-
obj = V8::External.new(Bar.new)
|
46
|
+
obj = Mustang::V8::External.new(Bar.new)
|
40
47
|
obj.delegate.bar.should == 'bar'
|
41
48
|
obj.bar.should == 'bar'
|
42
49
|
end
|
@@ -1,14 +1,21 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
2
|
|
3
|
-
describe V8::Function do
|
4
|
-
subject { V8::Function }
|
3
|
+
describe Mustang::V8::Function do
|
4
|
+
subject { Mustang::V8::Function }
|
5
5
|
setup_context
|
6
6
|
|
7
|
-
it "inherits V8::Object" do
|
8
|
-
subject.new(lambda { "foo" }).should be_kind_of(V8::Object)
|
7
|
+
it "inherits Mustang::V8::Object" do
|
8
|
+
subject.new(lambda { "foo" }).should be_kind_of(Mustang::V8::Object)
|
9
9
|
end
|
10
10
|
|
11
11
|
describe ".new" do
|
12
|
+
context "when no context entered" do
|
13
|
+
it "should raise error" do
|
14
|
+
Mustang::V8::Context.exit_all!
|
15
|
+
expect { subject.new(lambda {}) }.to raise_error(RuntimeError, "can't create V8 object without entering into context")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
12
19
|
context "when given proc/lambda" do
|
13
20
|
it "creates new function pointed to it" do
|
14
21
|
func = subject.new(lambda {|bar| "foo#{bar}"})
|
@@ -84,10 +91,10 @@ describe V8::Function do
|
|
84
91
|
|
85
92
|
context "when wrong numbers of arguments given" do
|
86
93
|
it "returns proper error" do
|
87
|
-
func = V8::Function.new(lambda {|arg| return arg })
|
94
|
+
func = Mustang::V8::Function.new(lambda {|arg| return arg })
|
88
95
|
func.call().should be_error
|
89
96
|
func.call(1).should == 1
|
90
|
-
func = V8::Function.new(lambda {|*args| return args.size })
|
97
|
+
func = Mustang::V8::Function.new(lambda {|*args| return args.size })
|
91
98
|
func.call().should == 0
|
92
99
|
func.call(1,2,3).should == 3
|
93
100
|
end
|
@@ -96,7 +103,7 @@ describe V8::Function do
|
|
96
103
|
|
97
104
|
describe "#bind" do
|
98
105
|
it "binds function with given object" do
|
99
|
-
func = V8::Function.new(lambda{})
|
106
|
+
func = Mustang::V8::Function.new(lambda{})
|
100
107
|
func.bind('foo')
|
101
108
|
func.receiver.should == 'foo'
|
102
109
|
end
|
@@ -105,14 +112,14 @@ describe V8::Function do
|
|
105
112
|
describe "#receiver" do
|
106
113
|
context "when no object bound to function" do
|
107
114
|
it "returns nil" do
|
108
|
-
func = V8::Function.new(lambda{})
|
115
|
+
func = Mustang::V8::Function.new(lambda{})
|
109
116
|
func.receiver.should_not be
|
110
117
|
end
|
111
118
|
end
|
112
119
|
|
113
120
|
context "when object bound to function" do
|
114
121
|
it "returns it" do
|
115
|
-
func = V8::Function.new(lambda{})
|
122
|
+
func = Mustang::V8::Function.new(lambda{})
|
116
123
|
func.bind(1)
|
117
124
|
func.receiver.should == 1
|
118
125
|
end
|
@@ -121,7 +128,7 @@ describe V8::Function do
|
|
121
128
|
|
122
129
|
describe "#name= and #name" do
|
123
130
|
it "sets and gets function's unique name" do
|
124
|
-
func = V8::Function.new(lambda{})
|
131
|
+
func = Mustang::V8::Function.new(lambda{})
|
125
132
|
func.name = 'foo'
|
126
133
|
func.name.should == 'foo'
|
127
134
|
end
|
@@ -131,7 +138,7 @@ describe V8::Function do
|
|
131
138
|
context "when function has been created from ruby proc/lambda/method" do
|
132
139
|
it "returns it" do
|
133
140
|
proc = Proc.new {}
|
134
|
-
func = V8::Function.new(proc)
|
141
|
+
func = Mustang::V8::Function.new(proc)
|
135
142
|
func.origin.should == proc
|
136
143
|
end
|
137
144
|
end
|
@@ -148,7 +155,7 @@ describe V8::Function do
|
|
148
155
|
context "when function has been created from ruby proc/lambda/method" do
|
149
156
|
it "returns it" do
|
150
157
|
proc = Proc.new {}
|
151
|
-
func = V8::Function.new(proc)
|
158
|
+
func = Mustang::V8::Function.new(proc)
|
152
159
|
func.to_proc.should == proc
|
153
160
|
end
|
154
161
|
end
|
@@ -1,15 +1,22 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
2
|
|
3
|
-
describe V8::Integer do
|
4
|
-
subject { V8::Integer }
|
3
|
+
describe Mustang::V8::Integer do
|
4
|
+
subject { Mustang::V8::Integer }
|
5
5
|
setup_context
|
6
6
|
|
7
|
-
it "inherits V8::Number" do
|
8
|
-
pending "Needs to separate V8::Number"
|
9
|
-
subject.new(10).should be_kind_of(V8::Number)
|
7
|
+
it "inherits Mustang::V8::Number" do
|
8
|
+
pending "Needs to separate Mustang::V8::Number"
|
9
|
+
subject.new(10).should be_kind_of(Mustang::V8::Number)
|
10
10
|
end
|
11
11
|
|
12
12
|
describe ".new" do
|
13
|
+
context "when no context entered" do
|
14
|
+
it "should raise error" do
|
15
|
+
Mustang::V8::Context.exit_all!
|
16
|
+
expect { subject.new(1) }.to raise_error(RuntimeError, "can't create V8 object without entering into context")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
13
20
|
it "creates new v8 integer based on passed value" do
|
14
21
|
subject.new(10).should == 10
|
15
22
|
subject.new(-10).should == -10
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
2
|
|
3
|
-
describe V8::Null do
|
3
|
+
describe Mustang::V8::Null do
|
4
4
|
setup_context
|
5
5
|
|
6
|
-
it "is kind of V8::NullClass" do
|
7
|
-
subject.should be_kind_of(V8::NullClass)
|
6
|
+
it "is kind of Mustang::V8::NullClass" do
|
7
|
+
subject.should be_kind_of(Mustang::V8::NullClass)
|
8
8
|
end
|
9
9
|
|
10
10
|
describe "#null?" do
|
@@ -1,11 +1,11 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
2
|
|
3
|
-
describe V8::Number do
|
4
|
-
subject { V8::Number }
|
3
|
+
describe Mustang::V8::Number do
|
4
|
+
subject { Mustang::V8::Number }
|
5
5
|
setup_context
|
6
6
|
|
7
|
-
it "inherits V8::Primitive" do
|
8
|
-
subject.new(10.5).should be_kind_of(V8::Primitive)
|
7
|
+
it "inherits Mustang::V8::Primitive" do
|
8
|
+
subject.new(10.5).should be_kind_of(Mustang::V8::Primitive)
|
9
9
|
end
|
10
10
|
|
11
11
|
describe ".new" do
|
@@ -1,16 +1,23 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
2
|
|
3
|
-
describe V8::Object do
|
4
|
-
subject { V8::Object }
|
3
|
+
describe Mustang::V8::Object do
|
4
|
+
subject { Mustang::V8::Object }
|
5
5
|
setup_context
|
6
6
|
|
7
|
-
it "inherits V8::Value" do
|
8
|
-
subject.new(:foo => 1).should be_kind_of(V8::Value)
|
7
|
+
it "inherits Mustang::V8::Value" do
|
8
|
+
subject.new(:foo => 1).should be_kind_of(Mustang::V8::Value)
|
9
9
|
end
|
10
10
|
|
11
11
|
describe ".new" do
|
12
|
+
context "when no context entered" do
|
13
|
+
it "should raise error" do
|
14
|
+
Mustang::V8::Context.exit_all!
|
15
|
+
expect { subject.new(1) }.to raise_error(RuntimeError, "can't create V8 object without entering into context")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
12
19
|
it "creates new v8 object" do
|
13
|
-
subject.new.should be_kind_of(V8::Object)
|
20
|
+
subject.new.should be_kind_of(Mustang::V8::Object)
|
14
21
|
end
|
15
22
|
|
16
23
|
context "when hash with properties passed" do
|
@@ -1,14 +1,21 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
2
|
|
3
|
-
describe V8::Regexp do
|
4
|
-
subject { V8::Regexp }
|
3
|
+
describe Mustang::V8::Regexp do
|
4
|
+
subject { Mustang::V8::Regexp }
|
5
5
|
setup_context
|
6
6
|
|
7
|
-
it "inherits V8::Number" do
|
8
|
-
subject.new(/foo(bar)?/).should be_kind_of(V8::Value)
|
7
|
+
it "inherits Mustang::V8::Number" do
|
8
|
+
subject.new(/foo(bar)?/).should be_kind_of(Mustang::V8::Value)
|
9
9
|
end
|
10
10
|
|
11
11
|
describe ".new" do
|
12
|
+
context "when no context entered" do
|
13
|
+
it "should raise error" do
|
14
|
+
Mustang::V8::Context.exit_all!
|
15
|
+
expect { subject.new(/foo/) }.to raise_error(RuntimeError, "can't create V8 object without entering into context")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
12
19
|
context "when ruby regexp passed" do
|
13
20
|
it "creates new v8 regexp based on it" do
|
14
21
|
subject.new(/foo(bar)?/im).should == /foo(bar)?/im
|
@@ -1,15 +1,22 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
require File.dirname(__FILE__) + '
|
2
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
3
3
|
|
4
|
-
describe V8::String do
|
5
|
-
subject { V8::String }
|
4
|
+
describe Mustang::V8::String do
|
5
|
+
subject { Mustang::V8::String }
|
6
6
|
setup_context
|
7
7
|
|
8
|
-
it "inherits V8::Primitive" do
|
9
|
-
subject.new("foo").should be_kind_of(V8::Primitive)
|
8
|
+
it "inherits Mustang::V8::Primitive" do
|
9
|
+
subject.new("foo").should be_kind_of(Mustang::V8::Primitive)
|
10
10
|
end
|
11
11
|
|
12
12
|
describe ".new" do
|
13
|
+
context "when no context entered" do
|
14
|
+
it "should raise error" do
|
15
|
+
Mustang::V8::Context.exit_all!
|
16
|
+
expect { subject.new("foo") }.to raise_error(RuntimeError, "can't create V8 object without entering into context")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
13
20
|
it "creates new v8 string based on passed value" do
|
14
21
|
subject.new("foo").to_s.should == "foo"
|
15
22
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
2
|
|
3
|
-
describe V8::Undefined do
|
3
|
+
describe Mustang::V8::Undefined do
|
4
4
|
setup_context
|
5
5
|
|
6
|
-
it "is kind of V8::UndefinedClass" do
|
7
|
-
subject.should be_kind_of(V8::UndefinedClass)
|
6
|
+
it "is kind of Mustang::V8::UndefinedClass" do
|
7
|
+
subject.should be_kind_of(Mustang::V8::UndefinedClass)
|
8
8
|
end
|
9
9
|
|
10
10
|
describe "#null?" do
|
@@ -0,0 +1,222 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe Mustang::V8::Value do
|
4
|
+
subject { Mustang::V8::Value }
|
5
|
+
setup_context
|
6
|
+
|
7
|
+
it "inherits Mustang::V8::Data" do
|
8
|
+
subject.new(Object.new).should be_kind_of(Mustang::V8::Data)
|
9
|
+
end
|
10
|
+
|
11
|
+
describe ".new" do
|
12
|
+
context "when no context entered" do
|
13
|
+
it "should raise error" do
|
14
|
+
Mustang::V8::Context.exit_all!
|
15
|
+
expect { subject.new(Object.new) }.to raise_error(RuntimeError, "can't create V8 object without entering into context")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it "creates new v8 value" do
|
20
|
+
subject.new(Object.new).should be_kind_of(Mustang::V8::Value)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#object?" do
|
25
|
+
it "returns true when value is an instance of Mustang::V8::Object" do
|
26
|
+
Mustang::V8::Object.new.should be_object
|
27
|
+
end
|
28
|
+
|
29
|
+
it "returns false when value is not an instance of Mustang::V8::Object" do
|
30
|
+
Mustang::V8::External.new(Object.new).should_not be_object
|
31
|
+
end
|
32
|
+
|
33
|
+
it "is aliased with #obj?" do
|
34
|
+
Mustang::V8::Object.new.should be_obj
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#integer?" do
|
39
|
+
it "returns true when value is an instance of Mustang::V8::Integer" do
|
40
|
+
Mustang::V8::Integer.new(10).should be_integer
|
41
|
+
end
|
42
|
+
|
43
|
+
it "returns false when value is not an instance of Mustang::V8::Integer" do
|
44
|
+
subject.new(Object.new).should_not be_integer
|
45
|
+
end
|
46
|
+
|
47
|
+
it "is aliased with #int?" do
|
48
|
+
Mustang::V8::Integer.new(10).should be_int
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "#number?" do
|
53
|
+
it "returns true when value is an instance of Mustang::V8::Number" do
|
54
|
+
Mustang::V8::Number.new(10).should be_number
|
55
|
+
end
|
56
|
+
|
57
|
+
it "returns false when value is not an instance of Mustang::V8::Number" do
|
58
|
+
subject.new(Object.new).should_not be_number
|
59
|
+
end
|
60
|
+
|
61
|
+
it "is aliased with #num?" do
|
62
|
+
Mustang::V8::Number.new(10).should be_num
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "#string?" do
|
67
|
+
it "returns true when value is an instance of Mustang::V8::String" do
|
68
|
+
Mustang::V8::String.new("foo").should be_string
|
69
|
+
end
|
70
|
+
|
71
|
+
it "returns false when value is not an instance of Mustang::V8::String" do
|
72
|
+
subject.new(Object.new).should_not be_string
|
73
|
+
end
|
74
|
+
|
75
|
+
it "is aliased with #str?" do
|
76
|
+
Mustang::V8::String.new("foo").should be_str
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "#external?" do
|
81
|
+
it "returns true when value is an instance of Mustang::V8::External" do
|
82
|
+
Mustang::V8::External.new(Object.new).should be_external
|
83
|
+
end
|
84
|
+
|
85
|
+
it "returns false when value is not an instance of Mustang::V8::External" do
|
86
|
+
Mustang::V8::Integer.new(10).should_not be_external
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "#array?" do
|
91
|
+
it "returns true when value is an instance of Mustang::V8::Array" do
|
92
|
+
Mustang::V8::Array.new(1,2,3).should be_array
|
93
|
+
end
|
94
|
+
|
95
|
+
it "returns false when value is not an instance of Mustang::V8::Array" do
|
96
|
+
subject.new(Object.new).should_not be_array
|
97
|
+
end
|
98
|
+
|
99
|
+
it "is aliased with #ary?" do
|
100
|
+
Mustang::V8::Array.new.should be_ary
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe "#function?" do
|
105
|
+
it "returns true when value is an instance of Mustang::V8::Function" do
|
106
|
+
Mustang::V8::Function.new(proc {}).should be_function
|
107
|
+
end
|
108
|
+
|
109
|
+
it "returns false when value is not an instance of Mustang::V8::Function" do
|
110
|
+
Mustang::V8::Integer.new(1).should_not be_function
|
111
|
+
end
|
112
|
+
|
113
|
+
it "is aliased with #func?" do
|
114
|
+
Mustang::V8::Function.new(proc {}).should be_func
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
describe "#regexp?" do
|
119
|
+
it "returns true when value is an instance of Mustang::V8::Regexp" do
|
120
|
+
Mustang::V8::Regexp.new(/foo/).should be_regexp
|
121
|
+
end
|
122
|
+
|
123
|
+
it "returns false when value is not an instance of Mustang::V8::Regexp" do
|
124
|
+
Mustang::V8::Integer.new(1).should_not be_regexp
|
125
|
+
end
|
126
|
+
|
127
|
+
it "is aliased with #regex?" do
|
128
|
+
Mustang::V8::Regexp.new(/foo/).should be_regex
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe "#date?" do
|
133
|
+
it "returns true when value is an instance of Mustang::V8::Date" do
|
134
|
+
Mustang::V8::Date.new(Time.now).should be_date
|
135
|
+
end
|
136
|
+
|
137
|
+
it "returns false when value is not an instance of Mustang::V8::Date" do
|
138
|
+
Mustang::V8::Integer.new(1).should_not be_date
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
describe "#to_integer" do
|
143
|
+
it "returns V8 integer representation of value" do
|
144
|
+
val = Mustang::V8::Integer.new(10)
|
145
|
+
subject.new(val).to_integer.should == val
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
describe "#to_string" do
|
150
|
+
it "returns V8 string representation of value" do
|
151
|
+
val = Mustang::V8::String.new("foo")
|
152
|
+
subject.new(val).to_string.should == val
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
describe "#to_number" do
|
157
|
+
it "returns V8 number representation of value" do
|
158
|
+
val = Mustang::V8::Number.new(10.5)
|
159
|
+
subject.new(val).to_number.should == val
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe "#to_object" do
|
164
|
+
it "returns V8 object representation of value" do
|
165
|
+
val = Mustang::V8::Object.new(:foo => 1)
|
166
|
+
subject.new(val).to_object.should == val
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
describe "#to_boolean" do
|
171
|
+
it "return V8 boolean representation of value" do
|
172
|
+
Mustang::V8::Object.new(:foo => 1).to_boolean.should be_true
|
173
|
+
Mustang::V8::Integer.new(0).to_boolean.should be_false
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
describe "#===" do
|
178
|
+
it "returns true when compared objects are strictly the same" do
|
179
|
+
obj = Mustang::V8::Object.new(:foo => 1)
|
180
|
+
val = subject.new(obj)
|
181
|
+
val.should === obj
|
182
|
+
end
|
183
|
+
|
184
|
+
it "returns false when compared objects are strictly different" do
|
185
|
+
obj = Mustang::V8::Object.new(:foo => 1)
|
186
|
+
val = subject.new(Mustang::V8::Array.new)
|
187
|
+
val.should_not === obj
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
describe "#==" do
|
192
|
+
it "returns true when compared objects are the same" do
|
193
|
+
obj1 = Mustang::V8::Integer.new(1)
|
194
|
+
obj2 = Mustang::V8::Integer.new(1)
|
195
|
+
subject.new(obj1).should == obj2
|
196
|
+
end
|
197
|
+
|
198
|
+
it "returns false when compared objects are different" do
|
199
|
+
obj1 = Mustang::V8::Object.new(:foo => 1)
|
200
|
+
obj2 = Mustang::V8::Object.new(:bar => 1)
|
201
|
+
subject.new(obj1).should_not == obj2
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
describe "null?" do
|
206
|
+
it "returns true when object is not null" do
|
207
|
+
Mustang::V8::Object.new.should_not be_null
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
describe "undefined?" do
|
212
|
+
it "returns true when object is not undefined" do
|
213
|
+
Mustang::V8::Object.new.should_not be_undefined
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
describe "empty?" do
|
218
|
+
it "returns true when object is not empty" do
|
219
|
+
Mustang::V8::Object.new.should_not be_empty
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|