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: 44af46261bd3
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0481ebfcc0a0
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Apr 15, 2016

  1. Copy the full SHA
    7fbd039 View commit details
  2. Copy the full SHA
    0481ebf View commit details
Showing with 121 additions and 21 deletions.
  1. +7 −21 spec/truffle/specs/truffle/array/append_spec.rb
  2. +114 −0 spec/truffle/specs/truffle/array/element_set_spec.rb
28 changes: 7 additions & 21 deletions spec/truffle/specs/truffle/array/append_spec.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
# Copyright (c) 2008 Engine Yard, Inc. All rights reserved.

# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:

# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. This
# code is released under a tri EPL/GPL/LGPL license. You can use it,
# redistribute it and/or modify it under the terms of the:
#
# Eclipse Public License version 1.0
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1
# OTHER DEALINGS IN THE SOFTWARE.

require_relative '../../../../ruby/spec_helper'
114 changes: 114 additions & 0 deletions spec/truffle/specs/truffle/array/element_set_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. This
# code is released under a tri EPL/GPL/LGPL license. You can use it,
# redistribute it and/or modify it under the terms of the:
#
# Eclipse Public License version 1.0
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

require_relative '../../../../ruby/spec_helper'

describe "Array#[]=" do
def storage(ary)
Truffle::Primitive.array_storage(ary)
end

before :each do
@long = 1 << 52
end

it "migrates to the most specific storage if initially empty" do
ary = []
ary[0] = Object.new
storage(ary).should == "Object[]"

ary = []
ary[0] = 3.14
storage(ary).should == "double[]"

ary = []
ary[0] = @long
storage(ary).should == "long[]"

ary = []
ary[0] = 1
storage(ary).should == "int[]"
end

it "keeps the same storage if compatible and in bounds" do
ary = [Object.new, Object.new]
ary[1] = Object.new
storage(ary).should == "Object[]"

ary = [3.11, 3.12]
ary[1] = 3.14
storage(ary).should == "double[]"

ary = [@long-2, @long-1]
ary[1] = @long
storage(ary).should == "long[]"

ary = [@long-2, @long-1]
ary[1] = 3
storage(ary).should == "long[]"

ary = [0, 1]
ary[1] = 2
storage(ary).should == "int[]"
end

it "generalizes if not compatible and in bounds" do
ary = [3.11, 3.12]
ary[1] = Object.new
storage(ary).should == "Object[]"

ary = [@long-2, @long-1]
ary[1] = 3.14
storage(ary).should == "Object[]"

ary = [0, 1]
ary[1] = @long
storage(ary).should == "long[]"

ary = [0, 1]
ary[1] = Object.new
storage(ary).should == "Object[]"
end

it "keeps the same storage if compatible and appending" do
ary = [Object.new, Object.new]
ary[2] = Object.new
storage(ary).should == "Object[]"

ary = [3.11, 3.12]
ary[2] = 3.14
storage(ary).should == "double[]"

ary = [@long-2, @long-1]
ary[2] = @long
storage(ary).should == "long[]"

ary = [0, 1]
ary[2] = 2
storage(ary).should == "int[]"
end

it "migrates to Object[] if writing out of bounds" do
ary = [Object.new, Object.new]
ary[3] = Object.new
storage(ary).should == "Object[]"

ary = [3.11, 3.12]
ary[3] = 3.14
storage(ary).should == "Object[]"

ary = [@long-2, @long-1]
ary[3] = @long
storage(ary).should == "Object[]"

ary = [0, 1]
ary[3] = 2
storage(ary).should == "Object[]"
end
end