Sha256: 46bad8a20339f4ccb35e9f359f4ad717d672b90be4b4f787b36039ecd993f054

Contents?: true

Size: 997 Bytes

Versions: 15

Compression:

Stored size: 997 Bytes

Contents

require 'minitest/autorun'
require 'geometry/vector'

describe Vector do
    describe "when monkeypatching Vector" do
	let(:left) { Vector[1,2] }
	let(:right) { Vector[3,4] }
	
	it "must have +@" do
	    (+left).must_equal Vector[1,2]
	end
	
	it "must have unary negation" do
	    (-left).must_equal Vector[-1,-2]
	end
	
	it "must cross product" do
	    left.cross(right).must_equal -2
	    Vector[1,2,3].cross(Vector[3,4,5]).must_equal Vector[-2, 4, -2]
	    (Vector[1,2,3] ** Vector[3,4,5]).must_equal Vector[-2, 4, -2]
	end

	it "must have a constant representing the X axis" do
	    Vector::X.must_equal Vector[1,0,0]
	end

	it "must have a constant representing the Y axis" do
	    Vector::Y.must_equal Vector[0,1,0]
	end

	it "must have a constant representing the Z axis" do
	    Vector::Z.must_equal Vector[0,0,1]
	end

	it "must not create global axis constants" do
	    -> { X }.must_raise NameError
	    -> { Y }.must_raise NameError
	    -> { Z }.must_raise NameError
	end
    end
end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
geometry-6.5 test/geometry/vector.rb
geometry-6.4 test/geometry/vector.rb
geometry-6.3 test/geometry/vector.rb
geometry-6.2 test/geometry/vector.rb
geometry-in-ruby-0.0.5 test/geometry/vector.rb
geometry-in-ruby-0.0.4 test/geometry/vector.rb
geometry-in-ruby-0.0.3 test/geometry/vector.rb
geometry-in-ruby-0.0.2 test/geometry/vector.rb
geometry-in-ruby-0.0.1 test/geometry/vector.rb
aurora-geometry-0.0.5 test/geometry/vector.rb
aurora-geometry-0.0.4 test/aurora-geometry/vector.rb
aurora-geometry-0.0.3 test/aurora-geometry/vector.rb
aurora-geometry-0.0.2 test/geometry/vector.rb
geometry-6.1 test/geometry/vector.rb
geometry-6 test/geometry/vector.rb