opal 0.6.3 → 0.7.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.spectator +2 -0
- data/.spectator-mspec +3 -0
- data/.travis.yml +8 -11
- data/CHANGELOG.md +33 -0
- data/CONTRIBUTING.md +8 -43
- data/Gemfile +15 -4
- data/Guardfile +77 -0
- data/README.md +15 -9
- data/Rakefile +36 -12
- data/benchmarks/operators.rb +11 -0
- data/bin/opal +10 -13
- data/bin/opal-build +4 -4
- data/bin/opal-mspec +10 -0
- data/bin/opal-repl +4 -3
- data/examples/sinatra/Gemfile +1 -1
- data/examples/sinatra/config.ru +3 -3
- data/lib/mspec/opal/main.rb.erb +2 -2
- data/lib/mspec/opal/rake_task.rb +31 -24
- data/lib/mspec/opal/runner.rb +18 -1
- data/lib/mspec/opal/sprockets.js +17 -0
- data/lib/opal.rb +1 -34
- data/lib/opal/builder.rb +92 -58
- data/lib/opal/builder_processors.rb +165 -0
- data/lib/opal/cli.rb +85 -144
- data/lib/opal/cli_options.rb +136 -90
- data/lib/opal/cli_runners.rb +10 -0
- data/lib/opal/cli_runners/nodejs.rb +56 -0
- data/lib/opal/cli_runners/phantom.js +35 -0
- data/lib/opal/cli_runners/phantomjs.rb +28 -0
- data/lib/opal/cli_runners/server.rb +54 -0
- data/lib/opal/compiler.rb +35 -16
- data/lib/opal/erb.rb +29 -15
- data/lib/opal/hike_path_finder.rb +18 -0
- data/lib/opal/nodes.rb +1 -0
- data/lib/opal/nodes/call.rb +107 -26
- data/lib/opal/nodes/call_special.rb +31 -6
- data/lib/opal/nodes/class.rb +2 -2
- data/lib/opal/nodes/constants.rb +5 -20
- data/lib/opal/nodes/def.rb +4 -4
- data/lib/opal/nodes/defined.rb +3 -3
- data/lib/opal/nodes/definitions.rb +1 -1
- data/lib/opal/nodes/for.rb +35 -0
- data/lib/opal/nodes/helpers.rb +2 -2
- data/lib/opal/nodes/iter.rb +3 -3
- data/lib/opal/nodes/literal.rb +10 -2
- data/lib/opal/nodes/masgn.rb +2 -2
- data/lib/opal/nodes/module.rb +2 -2
- data/lib/opal/nodes/scope.rb +1 -0
- data/lib/opal/nodes/singleton_class.rb +2 -2
- data/lib/opal/nodes/super.rb +2 -2
- data/lib/opal/nodes/top.rb +30 -3
- data/lib/opal/parser.rb +15 -1
- data/lib/opal/parser/grammar.rb +2571 -2452
- data/lib/opal/parser/grammar.y +37 -5
- data/lib/opal/parser/keywords.rb +2 -0
- data/lib/opal/parser/lexer.rb +21 -11
- data/lib/opal/path_reader.rb +28 -0
- data/lib/opal/paths.rb +38 -0
- data/lib/opal/source_map.rb +32 -15
- data/lib/opal/sprockets/environment.rb +9 -2
- data/lib/opal/sprockets/erb.rb +1 -2
- data/lib/opal/sprockets/path_reader.rb +34 -0
- data/lib/opal/sprockets/processor.rb +40 -39
- data/lib/opal/sprockets/server.rb +47 -33
- data/lib/opal/version.rb +1 -1
- data/opal.gemspec +10 -5
- data/opal/README.md +6 -0
- data/opal/corelib/array.rb +36 -4
- data/opal/corelib/array/inheritance.rb +6 -6
- data/opal/corelib/basic_object.rb +9 -9
- data/opal/corelib/boolean.rb +1 -1
- data/opal/corelib/class.rb +12 -12
- data/opal/corelib/dir.rb +20 -0
- data/opal/corelib/enumerable.rb +42 -42
- data/opal/corelib/enumerator.rb +1 -1
- data/opal/corelib/error.rb +2 -2
- data/opal/corelib/file.rb +56 -0
- data/opal/corelib/hash.rb +5 -5
- data/opal/corelib/helpers.rb +3 -3
- data/opal/corelib/io.rb +13 -10
- data/opal/corelib/kernel.rb +44 -68
- data/opal/corelib/method.rb +1 -1
- data/opal/corelib/module.rb +89 -114
- data/opal/corelib/nil_class.rb +1 -1
- data/opal/corelib/numeric.rb +27 -23
- data/opal/corelib/proc.rb +5 -5
- data/opal/corelib/range.rb +8 -4
- data/opal/corelib/regexp.rb +5 -5
- data/opal/corelib/runtime.js +589 -272
- data/opal/corelib/string.rb +52 -37
- data/opal/corelib/string/inheritance.rb +5 -5
- data/opal/corelib/time.rb +102 -52
- data/opal/corelib/variables.rb +3 -3
- data/opal/opal.rb +2 -0
- data/package.json +9 -0
- data/spec/filters/bugs/array.rb +0 -6
- data/spec/filters/bugs/language.rb +4 -0
- data/spec/filters/bugs/numeric.rb +7 -6
- data/spec/filters/bugs/opal.rb +2 -0
- data/spec/filters/bugs/regexp.rb +4 -0
- data/spec/filters/bugs/string.rb +0 -7
- data/spec/filters/bugs/stringscanner.rb +4 -1
- data/spec/filters/unsupported/private_methods.rb +2 -0
- data/spec/lib/builder_processors_spec.rb +27 -0
- data/spec/lib/builder_spec.rb +66 -0
- data/spec/{cli → lib}/cli_spec.rb +60 -5
- data/spec/{cli → lib}/compiler_spec.rb +66 -5
- data/spec/{cli → lib}/dependency_resolver_spec.rb +1 -1
- data/spec/lib/fixtures/no_requires.rb +1 -0
- data/spec/{cli → lib}/fixtures/opal_file.rb +0 -0
- data/spec/lib/fixtures/require_tree_test.rb +3 -0
- data/spec/lib/fixtures/required_tree_test/required_file1.rb +1 -0
- data/spec/lib/fixtures/required_tree_test/required_file2.rb +1 -0
- data/spec/lib/fixtures/requires.rb +7 -0
- data/spec/{cli → lib}/fixtures/sprockets_file.js.rb +0 -0
- data/spec/lib/fixtures/sprockets_require_tree_test.rb +3 -0
- data/spec/lib/hike_path_finder_spec.rb +23 -0
- data/spec/{cli → lib}/lexer_spec.rb +1 -1
- data/spec/{cli → lib}/parser/alias_spec.rb +1 -1
- data/spec/{cli → lib}/parser/and_spec.rb +1 -1
- data/spec/{cli → lib}/parser/attrasgn_spec.rb +1 -1
- data/spec/{cli → lib}/parser/begin_spec.rb +1 -1
- data/spec/{cli → lib}/parser/block_spec.rb +1 -1
- data/spec/{cli → lib}/parser/break_spec.rb +1 -1
- data/spec/{cli → lib}/parser/call_spec.rb +1 -1
- data/spec/{cli → lib}/parser/class_spec.rb +1 -1
- data/spec/{cli → lib}/parser/comments_spec.rb +1 -1
- data/spec/{cli → lib}/parser/def_spec.rb +1 -1
- data/spec/{cli → lib}/parser/if_spec.rb +1 -1
- data/spec/{cli → lib}/parser/iter_spec.rb +1 -1
- data/spec/{cli → lib}/parser/lambda_spec.rb +1 -1
- data/spec/{cli → lib}/parser/literal_spec.rb +1 -1
- data/spec/{cli → lib}/parser/masgn_spec.rb +1 -1
- data/spec/{cli → lib}/parser/module_spec.rb +1 -1
- data/spec/{cli → lib}/parser/not_spec.rb +1 -1
- data/spec/{cli → lib}/parser/op_asgn1_spec.rb +1 -1
- data/spec/{cli → lib}/parser/op_asgn2_spec.rb +1 -1
- data/spec/{cli → lib}/parser/or_spec.rb +1 -1
- data/spec/{cli → lib}/parser/return_spec.rb +1 -1
- data/spec/{cli → lib}/parser/sclass_spec.rb +1 -1
- data/spec/{cli → lib}/parser/string_spec.rb +8 -1
- data/spec/{cli → lib}/parser/super_spec.rb +1 -1
- data/spec/lib/parser/unary_spec.rb +48 -0
- data/spec/{cli → lib}/parser/undef_spec.rb +1 -1
- data/spec/{cli → lib}/parser/unless_spec.rb +1 -1
- data/spec/{cli → lib}/parser/variables_spec.rb +1 -1
- data/spec/{cli → lib}/parser/while_spec.rb +1 -1
- data/spec/{cli → lib}/parser/yield_spec.rb +1 -1
- data/spec/lib/path_reader_spec.rb +24 -0
- data/spec/lib/shared/path_finder_shared.rb +19 -0
- data/spec/lib/shared/path_reader_shared.rb +31 -0
- data/spec/lib/spec_helper.rb +9 -0
- data/spec/lib/sprockets/environment_spec.rb +30 -0
- data/spec/{cli → lib}/sprockets/erb_spec.rb +1 -1
- data/spec/lib/sprockets/path_reader_spec.rb +25 -0
- data/spec/{cli → lib}/sprockets/processor_spec.rb +9 -2
- data/spec/lib/sprockets/server_spec.rb +20 -0
- data/spec/opal/compiler/irb_spec.rb +11 -11
- data/spec/opal/core/fixtures/require_tree_files/file 1.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_files/file 2.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_files/file 3.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_files/file 4.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_files/file 5.rb +1 -0
- data/spec/opal/core/kernel/require_tree_spec.rb +7 -0
- data/spec/opal/core/kernel/respond_to_spec.rb +2 -2
- data/spec/opal/core/runtime/method_missing_spec.rb +19 -0
- data/spec/opal/core/source_map_spec.rb +2 -2
- data/spec/opal/core/string_spec.rb +11 -0
- data/spec/opal/stdlib/erb/erb_spec.rb +0 -1
- data/spec/opal/stdlib/thread/mutex_spec.rb +40 -0
- data/spec/opal/stdlib/thread/thread_queue_spec.rb +32 -0
- data/spec/opal/stdlib/thread/thread_spec.rb +60 -0
- data/spec/rubyspecs +54 -11
- data/spec/spec_helper.rb +18 -3
- data/spec/support/mspec_rspec_adapter.rb +33 -0
- data/spec/{cli/spec_helper.rb → support/parser_helpers.rb} +10 -10
- data/stdlib/README.md +3 -0
- data/stdlib/benchmark.rb +10 -0
- data/stdlib/date.rb +2 -2
- data/stdlib/dir.rb +1 -5
- data/stdlib/file.rb +1 -7
- data/stdlib/json.rb +10 -1
- data/stdlib/native.rb +5 -5
- data/stdlib/nodejs.rb +5 -0
- data/stdlib/nodejs/dir.rb +13 -0
- data/stdlib/nodejs/file.rb +98 -0
- data/stdlib/nodejs/fileutils.rb +26 -0
- data/stdlib/nodejs/io.rb +2 -0
- data/stdlib/nodejs/irb.rb +45 -0
- data/stdlib/nodejs/process.rb +16 -0
- data/stdlib/nodejs/require.rb +32 -0
- data/stdlib/nodejs/rubygems.rb +68 -0
- data/stdlib/nodejs/runtime.rb +25 -0
- data/stdlib/nodejs/yaml.rb +11 -0
- data/stdlib/opal-parser.rb +1 -2
- data/stdlib/opal-source-maps.rb +2 -0
- data/stdlib/phantomjs.rb +8 -0
- data/stdlib/process.rb +10 -0
- data/stdlib/promise.rb +12 -4
- data/stdlib/set.rb +27 -0
- data/stdlib/source_map.rb +5 -63
- data/stdlib/source_map/map.rb +220 -0
- data/stdlib/source_map/mapping.rb +26 -0
- data/stdlib/source_map/offset.rb +88 -0
- data/stdlib/source_map/version.rb +3 -0
- data/stdlib/source_map/vlq.rb +77 -101
- data/stdlib/sourcemap.rb +1 -0
- data/stdlib/strscan.rb +7 -1
- data/stdlib/template.rb +1 -1
- data/stdlib/thread.rb +147 -7
- metadata +238 -104
- data/lib/mspec/opal/mspec_fixes.rb +0 -87
- data/spec/cli/sprockets/environment_spec.rb +0 -14
- data/spec/filters/bugs/symbol.rb +0 -5
- data/spec/opal/core/kernel/warn_spec.rb +0 -83
- data/spec/opal/core/language/numbers_spec.rb +0 -60
- data/stdlib/opal-source-maps.js.erb +0 -2
- data/stdlib/source_map/generator.rb +0 -251
- data/stdlib/source_map/parser.rb +0 -102
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'lib/spec_helper'
|
2
|
+
require 'lib/shared/path_reader_shared'
|
3
|
+
require 'opal/sprockets/path_reader'
|
4
|
+
|
5
|
+
describe Opal::Sprockets::PathReader do
|
6
|
+
subject(:path_reader) { described_class.new(env, context) }
|
7
|
+
|
8
|
+
let(:env) { Opal::Environment.new }
|
9
|
+
let(:context) { double('context', depend_on: nil, depend_on_asset: nil) }
|
10
|
+
|
11
|
+
let(:logical_path) { 'sprockets_file' }
|
12
|
+
let(:fixtures_dir) { File.expand_path('../../fixtures/', __FILE__) }
|
13
|
+
let(:full_path) { File.join(fixtures_dir, logical_path+'.js.rb') }
|
14
|
+
let(:contents) { File.read(full_path) }
|
15
|
+
|
16
|
+
before { env.append_path fixtures_dir }
|
17
|
+
|
18
|
+
include_examples :path_reader do
|
19
|
+
let(:path) { logical_path }
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'can read stuff from sprockets env' do
|
23
|
+
expect(path_reader.read(logical_path)).to eq(contents)
|
24
|
+
end
|
25
|
+
end
|
@@ -1,9 +1,16 @@
|
|
1
|
-
require '
|
1
|
+
require 'lib/spec_helper'
|
2
2
|
require 'opal/sprockets/processor'
|
3
3
|
|
4
4
|
describe Opal::Processor do
|
5
5
|
let(:pathname) { Pathname("/Code/app/mylib/opal/foo.#{ext}") }
|
6
|
-
let(:_context) { double('_context', :logical_path => "foo.#{ext}", :pathname => pathname
|
6
|
+
let(:_context) { double('_context', :logical_path => "foo.#{ext}", :pathname => pathname) }
|
7
|
+
let(:env) { double('env') }
|
8
|
+
|
9
|
+
before do
|
10
|
+
env.stub(:resolve) { pathname.expand_path.to_s }
|
11
|
+
env.stub(:[])
|
12
|
+
_context.stub(:environment) { env }
|
13
|
+
end
|
7
14
|
|
8
15
|
%w[rb js.rb opal js.opal].each do |ext|
|
9
16
|
let(:ext) { ext }
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'lib/spec_helper'
|
2
|
+
require 'rack/test'
|
3
|
+
|
4
|
+
describe Opal::Server do
|
5
|
+
include Rack::Test::Methods
|
6
|
+
|
7
|
+
def app
|
8
|
+
described_class.new { |s|
|
9
|
+
s.main = 'opal'
|
10
|
+
s.debug = false
|
11
|
+
s.sprockets.logger = Logger.new('/dev/null')
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'serves assets from /assets' do
|
16
|
+
get '/assets/opal.js'
|
17
|
+
expect(last_response).to be_ok
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -3,42 +3,42 @@ require 'native'
|
|
3
3
|
|
4
4
|
describe Opal::Compiler do
|
5
5
|
describe "irb parser option" do
|
6
|
-
before do
|
7
|
-
@compiler = Opal::Compiler.new
|
8
|
-
end
|
9
|
-
|
10
6
|
it "creates Opal.irb_vars if it does not exist" do
|
11
7
|
$global["Opal"].irb_vars = nil
|
12
|
-
eval_js(
|
8
|
+
eval_js compile("nil", :irb => true)
|
13
9
|
|
14
10
|
($global["Opal"].irb_vars == nil).should be_false
|
15
11
|
end
|
16
12
|
|
17
13
|
it "does not create Opal.irb_vars if :irb option not passed" do
|
18
14
|
$global["Opal"].irb_vars = nil
|
19
|
-
eval_js(
|
15
|
+
eval_js compile("nil")
|
20
16
|
|
21
17
|
($global["Opal"].irb_vars == nil).should be_true
|
22
18
|
end
|
23
19
|
|
24
20
|
it "sets each s(:lasgn) in the top level onto irb_vars" do
|
25
|
-
eval_js
|
21
|
+
eval_js compile("foo = 42", :irb => true)
|
26
22
|
$global["Opal"].irb_vars.foo.should == 42
|
27
23
|
end
|
28
24
|
|
29
25
|
it "gets each s(:lvar) in the top level from irb_vars" do
|
30
|
-
eval_js
|
26
|
+
eval_js compile("foo = 3.142; bar = foo", :irb => true)
|
31
27
|
$global["Opal"].irb_vars.bar.should == 3.142
|
32
28
|
end
|
33
29
|
|
34
30
|
it "persists local vars between parses" do
|
35
|
-
eval_js
|
36
|
-
eval_js
|
31
|
+
eval_js compile("foo = 'hello world'", :irb => true)
|
32
|
+
eval_js compile("bar = foo.upcase", :irb => true)
|
37
33
|
$global["Opal"].irb_vars.bar.should == "HELLO WORLD"
|
38
34
|
end
|
39
35
|
|
40
36
|
it "can still call top level methods" do
|
41
|
-
eval_js(
|
37
|
+
eval_js(compile("to_s", :irb => true)).should == "main"
|
38
|
+
end
|
39
|
+
|
40
|
+
def compile *args
|
41
|
+
Opal::Compiler.new(*args).compile
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
$ScratchPad << File.basename(__FILE__)
|
@@ -0,0 +1 @@
|
|
1
|
+
$ScratchPad << File.basename(__FILE__)
|
@@ -0,0 +1 @@
|
|
1
|
+
$ScratchPad << File.basename(__FILE__)
|
@@ -0,0 +1 @@
|
|
1
|
+
$ScratchPad << File.basename(__FILE__)
|
@@ -0,0 +1 @@
|
|
1
|
+
$ScratchPad << File.basename(__FILE__)
|
@@ -34,8 +34,8 @@ describe "Kernel#respond_to?" do
|
|
34
34
|
@a.respond_to?(:undefed_method).should be_false
|
35
35
|
end
|
36
36
|
|
37
|
-
it "returns false if a method exists, but is marked with a '
|
38
|
-
`#{@a}.$some_method
|
37
|
+
it "returns false if a method exists, but is marked with a '$$stub' property" do
|
38
|
+
`#{@a}.$some_method.$$stub = true`
|
39
39
|
@a.respond_to?(:some_method).should be_false
|
40
40
|
end
|
41
41
|
end
|
@@ -14,6 +14,9 @@ module MethodMissingSpecs
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
+
class BridgedClass < `(function NativeConstructor(){})`
|
18
|
+
end
|
19
|
+
|
17
20
|
describe "method_missing" do
|
18
21
|
before do
|
19
22
|
@obj = MethodMissingSpecs::A.new
|
@@ -41,3 +44,19 @@ describe "BasicObject#method_missing" do
|
|
41
44
|
}.should raise_error(Exception)
|
42
45
|
end
|
43
46
|
end
|
47
|
+
|
48
|
+
describe "Array#method_missing" do
|
49
|
+
it "raises an error for the missing method" do
|
50
|
+
lambda {
|
51
|
+
BasicObject.new.foo_bar_baz
|
52
|
+
}.should raise_error(Exception)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "<BridgedClass>#method_missing" do
|
57
|
+
it "raises an error for the missing method" do
|
58
|
+
lambda {
|
59
|
+
BridgedClass.new.foo_bar_baz
|
60
|
+
}.should raise_error(Exception)
|
61
|
+
end
|
62
|
+
end
|
@@ -4,8 +4,8 @@ require 'opal-source-maps'
|
|
4
4
|
describe Opal::SourceMap do
|
5
5
|
before do
|
6
6
|
pathname = 'foo.rb'
|
7
|
-
compiler = Opal::Compiler.new
|
8
|
-
@source = compiler.compile
|
7
|
+
compiler = Opal::Compiler.new("1 + 1", :file => pathname)
|
8
|
+
@source = compiler.compile
|
9
9
|
@map = Opal::SourceMap.new(compiler.fragments, pathname)
|
10
10
|
end
|
11
11
|
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'thread'
|
2
|
+
|
3
|
+
describe Mutex do
|
4
|
+
before do
|
5
|
+
@mutex = Mutex.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "cannot be locked twice" do
|
9
|
+
@mutex.lock
|
10
|
+
lambda do
|
11
|
+
@mutex.lock
|
12
|
+
end.should raise_error(ThreadError)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "reports locked? status" do
|
16
|
+
@mutex.locked?.should be_false
|
17
|
+
@mutex.lock
|
18
|
+
@mutex.locked?.should be_true
|
19
|
+
end
|
20
|
+
|
21
|
+
it "reports locked? status with try_lock" do
|
22
|
+
@mutex.try_lock.should be_true
|
23
|
+
@mutex.locked?.should be_true
|
24
|
+
@mutex.try_lock.should be_false
|
25
|
+
end
|
26
|
+
|
27
|
+
it "is locked and unlocked by synchronize" do
|
28
|
+
@mutex.synchronize do
|
29
|
+
@mutex.locked?.should be_true
|
30
|
+
end
|
31
|
+
@mutex.locked?.should be_false
|
32
|
+
end
|
33
|
+
|
34
|
+
it "will not be locked by synchronize if already locked" do
|
35
|
+
@mutex.lock
|
36
|
+
lambda do
|
37
|
+
@mutex.synchronize {}
|
38
|
+
end.should raise_error(ThreadError)
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'thread'
|
2
|
+
|
3
|
+
describe Thread::Queue do
|
4
|
+
before do
|
5
|
+
@queue = Thread::Queue.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "is aliased as ::Queue" do
|
9
|
+
::Thread::Queue.should == ::Queue
|
10
|
+
end
|
11
|
+
|
12
|
+
it "will not allow deadlock" do
|
13
|
+
lambda do
|
14
|
+
@queue.pop
|
15
|
+
end.should raise_error(ThreadError)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "pops in FIFO order" do
|
19
|
+
@queue.push(1)
|
20
|
+
@queue.push(2)
|
21
|
+
|
22
|
+
@queue.pop.should == 1
|
23
|
+
@queue.pop.should == 2
|
24
|
+
end
|
25
|
+
|
26
|
+
it "can be cleared by clear" do
|
27
|
+
@queue.push(1)
|
28
|
+
@queue.clear
|
29
|
+
@queue.size.should == 0
|
30
|
+
@queue.empty?.should be_true
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'thread'
|
2
|
+
|
3
|
+
# Our implementation of Thread only supports faux thread-local variables.
|
4
|
+
# Since we can't actually create a thread, nothing in rubyspec will run.
|
5
|
+
describe Thread do
|
6
|
+
it "returns a value for current" do
|
7
|
+
Thread.current.should_not be_nil
|
8
|
+
end
|
9
|
+
|
10
|
+
it "only has current in list" do
|
11
|
+
Thread.list.should == [Thread.current]
|
12
|
+
end
|
13
|
+
|
14
|
+
it "does not allow creation of new threads" do
|
15
|
+
lambda do
|
16
|
+
Thread.new {}
|
17
|
+
end.should raise_error(NotImplementedError)
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "local storage" do
|
21
|
+
before do
|
22
|
+
@current = Thread.current
|
23
|
+
@current.send(:core_initialize!)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "stores fiber-local variables" do
|
27
|
+
@current[:a] = 'hello'
|
28
|
+
@current[:a].should == 'hello'
|
29
|
+
end
|
30
|
+
|
31
|
+
it "returns fiber-local keys that are assigned" do
|
32
|
+
@current[:a] = 'hello'
|
33
|
+
@current.key?(:a).should be_true
|
34
|
+
@current.keys.should === ['a']
|
35
|
+
end
|
36
|
+
|
37
|
+
it "considers fiber-local keys, as symbols or strings equal" do
|
38
|
+
@current[:a] = 1
|
39
|
+
@current['a'] = 2
|
40
|
+
@current.keys.size.should == 1
|
41
|
+
@current[:a].should == 2
|
42
|
+
end
|
43
|
+
|
44
|
+
it "implements thread-local variables" do
|
45
|
+
@current.thread_variable_set('a', 1)
|
46
|
+
@current.thread_variable_get('a').should == 1
|
47
|
+
@current.thread_variables.should == ['a']
|
48
|
+
end
|
49
|
+
|
50
|
+
it "distinguishes between fiber-local and thread-local variables" do
|
51
|
+
@current[:a] = 1
|
52
|
+
@current.thread_variables.should == []
|
53
|
+
|
54
|
+
@current.thread_variable_set(:a, 2)
|
55
|
+
|
56
|
+
@current[:a].should == 1
|
57
|
+
@current.thread_variable_get(:a).should == 2
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/spec/rubyspecs
CHANGED
@@ -20,6 +20,7 @@ corelib/core/fixnum/even_spec
|
|
20
20
|
corelib/core/fixnum/gt_spec
|
21
21
|
corelib/core/fixnum/gte_spec
|
22
22
|
corelib/core/fixnum/left_shift_spec
|
23
|
+
corelib/core/fixnum/right_shift_spec
|
23
24
|
corelib/core/fixnum/lt_spec
|
24
25
|
corelib/core/fixnum/lte_spec
|
25
26
|
corelib/core/fixnum/magnitude_spec
|
@@ -42,11 +43,22 @@ corelib/core/kernel/equal_spec
|
|
42
43
|
corelib/core/kernel/equal_value_spec
|
43
44
|
corelib/core/kernel/tap_spec
|
44
45
|
corelib/core/kernel/to_s_spec
|
46
|
+
corelib/core/kernel/warn_spec
|
45
47
|
|
48
|
+
corelib/core/matchdata/captures_spec
|
49
|
+
corelib/core/matchdata/inspect_spec
|
50
|
+
corelib/core/matchdata/length_spec
|
51
|
+
corelib/core/matchdata/regexp_spec
|
52
|
+
corelib/core/matchdata/size_spec
|
53
|
+
corelib/core/matchdata/string_spec
|
46
54
|
corelib/core/matchdata/to_a_spec
|
55
|
+
corelib/core/matchdata/to_s_spec
|
56
|
+
corelib/core/matchdata/values_at_spec
|
47
57
|
|
48
58
|
corelib/core/range/begin_spec
|
59
|
+
corelib/core/range/case_compare_spec
|
49
60
|
corelib/core/range/end_spec
|
61
|
+
corelib/core/range/new_spec
|
50
62
|
corelib/core/range/size_spec
|
51
63
|
|
52
64
|
corelib/core/string/allocate_spec
|
@@ -77,14 +89,12 @@ corelib/core/string/each_byte_spec
|
|
77
89
|
corelib/core/string/each_char_spec
|
78
90
|
corelib/core/string/each_codepoint_spec
|
79
91
|
corelib/core/string/each_line_spec
|
80
|
-
corelib/core/string/each_spec
|
81
92
|
# corelib/core/string/element_reference_spec - fails to find a shared group - "String#[] with Regexp"
|
82
93
|
corelib/core/string/element_set_spec
|
83
94
|
corelib/core/string/empty_spec
|
84
95
|
corelib/core/string/encode_spec
|
85
96
|
corelib/core/string/encoding_spec
|
86
97
|
corelib/core/string/end_with_spec
|
87
|
-
corelib/core/string/entries_spec
|
88
98
|
corelib/core/string/eql_spec
|
89
99
|
corelib/core/string/equal_value_spec
|
90
100
|
corelib/core/string/force_encoding_spec
|
@@ -130,7 +140,6 @@ corelib/core/string/sub_spec
|
|
130
140
|
corelib/core/string/succ_spec
|
131
141
|
corelib/core/string/sum_spec
|
132
142
|
corelib/core/string/swapcase_spec
|
133
|
-
corelib/core/string/to_a_spec
|
134
143
|
# corelib/core/string/to_c_spec - lots of failing specs
|
135
144
|
corelib/core/string/to_f_spec
|
136
145
|
# corelib/core/string/to_i_spec
|
@@ -174,7 +183,6 @@ corelib/core/time/sec_spec
|
|
174
183
|
corelib/core/time/strftime_spec
|
175
184
|
corelib/core/time/sunday_spec
|
176
185
|
corelib/core/time/thursday_spec
|
177
|
-
corelib/core/time/times_spec
|
178
186
|
corelib/core/time/to_i_spec
|
179
187
|
corelib/core/time/to_s_spec
|
180
188
|
corelib/core/time/tuesday_spec
|
@@ -185,6 +193,9 @@ corelib/core/time/wednesday_spec
|
|
185
193
|
corelib/core/time/yday_spec
|
186
194
|
corelib/core/time/year_spec
|
187
195
|
|
196
|
+
corelib/core/regexp/case_compare_spec
|
197
|
+
corelib/core/regexp/eql_spec
|
198
|
+
corelib/core/regexp/equal_value_spec
|
188
199
|
corelib/core/regexp/escape_spec
|
189
200
|
corelib/core/regexp/match_spec
|
190
201
|
corelib/core/regexp/quote_spec
|
@@ -204,10 +215,10 @@ corelib/language/defined_spec
|
|
204
215
|
# corelib/language/encoding_spec - can't parse encodings
|
205
216
|
corelib/language/ensure_spec
|
206
217
|
# corelib/language/execution_spec - can't parse x-strings with shell commands
|
207
|
-
|
208
|
-
|
218
|
+
corelib/language/file_spec
|
219
|
+
corelib/language/for_spec
|
209
220
|
corelib/language/hash_spec
|
210
|
-
|
221
|
+
corelib/language/if_spec
|
211
222
|
# corelib/language/line_spec - $LOADED_FEATURES not present
|
212
223
|
# corelib/language/lambda_spec - Can't parse literal {} in parenthesized argument list
|
213
224
|
corelib/language/loop_spec
|
@@ -217,7 +228,7 @@ corelib/language/metaclass_spec
|
|
217
228
|
corelib/language/module_spec
|
218
229
|
# corelib/language/next_spec - can't parse break expr with block
|
219
230
|
corelib/language/not_spec
|
220
|
-
|
231
|
+
corelib/language/numbers_spec
|
221
232
|
corelib/language/or_spec
|
222
233
|
corelib/language/order_spec
|
223
234
|
corelib/language/precedence_spec
|
@@ -237,7 +248,7 @@ corelib/language/super_spec
|
|
237
248
|
# corelib/language/symbol_spec - lots fail
|
238
249
|
# corelib/language/throw_spec - unsupported
|
239
250
|
corelib/language/undef_spec
|
240
|
-
|
251
|
+
corelib/language/unless_spec
|
241
252
|
corelib/language/until_spec
|
242
253
|
# corelib/language/variables_spec - can't parse whole file
|
243
254
|
corelib/language/while_spec
|
@@ -259,21 +270,53 @@ stdlib/rubysl-delegate/spec/delegator/send_spec
|
|
259
270
|
|
260
271
|
stdlib/rubysl-erb/spec/util/html_escape_spec
|
261
272
|
|
262
|
-
stdlib/rubysl-set/spec/initialize_spec
|
263
273
|
stdlib/rubysl-set/spec/add_spec
|
264
274
|
stdlib/rubysl-set/spec/append_spec
|
265
275
|
stdlib/rubysl-set/spec/clear_spec
|
266
276
|
stdlib/rubysl-set/spec/constructor_spec
|
277
|
+
stdlib/rubysl-set/spec/delete_if_spec
|
278
|
+
stdlib/rubysl-set/spec/delete_spec
|
267
279
|
stdlib/rubysl-set/spec/each_spec
|
268
280
|
stdlib/rubysl-set/spec/empty_spec
|
281
|
+
stdlib/rubysl-set/spec/enumerable/to_set_spec
|
269
282
|
stdlib/rubysl-set/spec/equal_value_spec
|
270
283
|
stdlib/rubysl-set/spec/include_spec
|
284
|
+
stdlib/rubysl-set/spec/initialize_spec
|
271
285
|
stdlib/rubysl-set/spec/length_spec
|
272
286
|
stdlib/rubysl-set/spec/member_spec
|
273
287
|
stdlib/rubysl-set/spec/merge_spec
|
274
288
|
stdlib/rubysl-set/spec/size_spec
|
275
289
|
stdlib/rubysl-set/spec/to_a_spec
|
276
|
-
stdlib/rubysl-set/spec/
|
290
|
+
# stdlib/rubysl-set/spec/classify_spec
|
291
|
+
# stdlib/rubysl-set/spec/collect_spec
|
292
|
+
# stdlib/rubysl-set/spec/difference_spec
|
293
|
+
# stdlib/rubysl-set/spec/divide_spec
|
294
|
+
# stdlib/rubysl-set/spec/eql_spec
|
295
|
+
# stdlib/rubysl-set/spec/exclusion_spec
|
296
|
+
# stdlib/rubysl-set/spec/flatten_merge_spec
|
297
|
+
# stdlib/rubysl-set/spec/flatten_spec
|
298
|
+
# stdlib/rubysl-set/spec/hash_spec
|
299
|
+
# stdlib/rubysl-set/spec/initialize_copy_spec
|
300
|
+
# stdlib/rubysl-set/spec/inspect_spec
|
301
|
+
# stdlib/rubysl-set/spec/intersection_spec
|
302
|
+
# stdlib/rubysl-set/spec/keep_if_spec
|
303
|
+
# stdlib/rubysl-set/spec/map_spec
|
304
|
+
# stdlib/rubysl-set/spec/minus_spec
|
305
|
+
# stdlib/rubysl-set/spec/plus_spec
|
306
|
+
# stdlib/rubysl-set/spec/pretty_print_cycle_spec
|
307
|
+
# stdlib/rubysl-set/spec/pretty_print_spec
|
308
|
+
# stdlib/rubysl-set/spec/proper_subset_spec
|
309
|
+
# stdlib/rubysl-set/spec/proper_superset_spec
|
310
|
+
# stdlib/rubysl-set/spec/reject_spec
|
311
|
+
# stdlib/rubysl-set/spec/replace_spec
|
312
|
+
# stdlib/rubysl-set/spec/select_spec
|
313
|
+
# stdlib/rubysl-set/spec/subset_spec
|
314
|
+
# stdlib/rubysl-set/spec/subtract_spec
|
315
|
+
# stdlib/rubysl-set/spec/superset_spec
|
316
|
+
# stdlib/rubysl-set/spec/union_spec
|
317
|
+
|
318
|
+
|
319
|
+
|
277
320
|
|
278
321
|
stdlib/rubysl-pathname/spec/new_spec
|
279
322
|
stdlib/rubysl-pathname/spec/equal_value_spec
|