Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1ac43bb79b89
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7d6fa8405d59
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Mar 14, 2016

  1. Copy the full SHA
    1ecc79c View commit details
  2. Copy the full SHA
    7d6fa84 View commit details
Showing with 45 additions and 3 deletions.
  1. +23 −0 spec/jrubyc/java/files/hashy_kwargs.rb
  2. +22 −3 spec/jrubyc/java/loading_spec.rb
23 changes: 23 additions & 0 deletions spec/jrubyc/java/files/hashy_kwargs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module HashyKwargs

DEFAULT_ARGS = { 'str' => 1, sym: 2 }
private_constant :DEFAULT_ARGS

def generic(*args, **kwargs, &block)
[ args, kwargs, block ]
end

def self.kwargs1(sym: 1, sec: 2)
sym || DEFAULT_ARGS[:sym]
end

def self.kwargs2(req:, **opts); [ req, opts ] end

DEFAULT_ARGS['foo'] || DEFAULT_ARGS['str']

Hash.new.tap do |hash|
hash['one'] = 11 / 10; hash['two'] = 22 / 10
@@hash_one = hash['tri'] || hash['one']
end

end
25 changes: 22 additions & 3 deletions spec/jrubyc/java/loading_spec.rb
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ def compile_files(files)
it "loads double_rescue.class" do
load File.join(FILES_DIR, 'double_rescue.class')

expect( defined?(DoubleRescue) ).to be_truthy
expect( Object.const_defined?(:DoubleRescue) ).to be true
DoubleRescue.new._call

expect( DoubleRescue.re_raise_return ).to be_a LoadError
@@ -35,15 +35,34 @@ def compile_files(files)
it "loads sample_block.class" do
load File.join(FILES_DIR, 'sample_block.class')

expect( defined?(SampleBlock) ).to be_truthy
expect( Object.const_defined?(:SampleBlock) ).to be true
expect( SampleBlock.class_variable_get :@@func ).to eql '11'
end

it "deserializes symbol_proc.class" do
load File.join(FILES_DIR, 'symbol_proc.class')

expect( $symbol_proc_result ).to be_truthy
expect( $symbol_proc_result ).to_not be nil
expect( $symbol_proc_result ).to eql [ 1, 2, 3 ]
end

it "compiles hashy_kwargs.class correctly" do
load File.join(FILES_DIR, 'hashy_kwargs.class')

expect( Object.const_defined?(:HashyKwargs) ).to be true
klass = Class.new { include HashyKwargs }
res = klass.new.generic('0', 111, arg: 1) { 'block' }
pending 'FIXME if you wonder!'
expect( res[0] ).to eql [ '0', 111 ]
expect( res[1] ).to eql({ :arg => 1 })
expect( res[2].call ).to eql 'block'
expect( res.size ).to be 3

expect( HashyKwargs.kwargs1(sec: '2') ).to eql 1
expect( HashyKwargs.kwargs1(sym: false) ).to eql 2

res = HashyKwargs.kwargs2(foo: :bar, baz: 0, req: true)
expect( res ).to eql [ true, { :foo => :bar, :baz => 0 }]
end

end