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