Sha256: 04fc7769b1d77e15475b3406ad352b5d5d171c48f20fa0803937011b6f383397

Contents?: true

Size: 1.3 KB

Versions: 4

Compression:

Stored size: 1.3 KB

Contents

require File.expand_path(File.dirname(__FILE__)) + '/helpers.rb'

context "an int array" do
  setup { Ray::GL::IntArray.new }

  asserts(:[], 0).nil
  asserts(:size).equals 0

  context "with new elements" do
    hookup { topic << 3 << 0 << 1 }

    asserts(:[], 0).equals 3
    asserts(:[], 1).equals 0
    asserts(:[], 2).equals 1
    asserts(:[], 3).nil

    asserts(:size).equals 3
    asserts(:to_a).equals [3, 0, 1]

    context "one of which was changed" do
      hookup { topic[1] = 2 }

      asserts(:[], 0).equals 3
      asserts(:[], 1).equals 2
      asserts(:[], 2).equals 1
      asserts(:[], 3).nil

      asserts(:size).equals 3
      asserts(:to_a).equals [3, 2, 1]
    end

    context "but cleared" do
      hookup { topic.clear }

      asserts(:to_a).equals []
      asserts(:size).equals 0
    end

    context "copied" do
      setup { topic.dup }

      asserts(:size).equals 3
      asserts(:to_a).equals [3, 0, 1]
    end
  end

  context "resized with []=" do
    hookup { topic[1] = 5 }

    asserts(:[], 0).equals 0
    asserts(:[], 1).equals 5
    asserts(:[], 2).nil

    asserts(:size).equals 2
    asserts(:to_a).equals [0, 5]
  end
end

context "an int array created with values" do
  setup { Ray::GL::IntArray.new 0, 5, 4 }
  asserts(:to_a).equals [0, 5, 4]
end

run_tests if __FILE__ == $0

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ray-0.2.1 test/int_array_test.rb
ray-0.2.0 test/int_array_test.rb
ray-0.1.1 test/int_array_test.rb
ray-0.1.0 test/int_array_test.rb