Sha256: 6b094afefef39a524cc7358d22526b53a746486a259039fb1dc17296b52e429a

Contents?: true

Size: 1.42 KB

Versions: 15

Compression:

Stored size: 1.42 KB

Contents

require 'minitest/autorun'
require 'geometry/transformation/composition'

describe Geometry::Transformation::Composition do
    Composition = Geometry::Transformation::Composition
    Transformation = Geometry::Transformation

    subject { Composition.new }

    describe "when constructed" do
	it "must accept multiple transformations" do
	    composition = Composition.new(Transformation.new, Transformation.new)
	    composition.size.must_equal 2
	end

	it "must reject anything that isn't a Transformation" do
	    -> { Composition.new :foo }.must_raise TypeError
	end
    end

    describe "attributes" do
	describe "has_rotation?" do
	    it "must properly be true" do
		Composition.new(Transformation.new angle:90).has_rotation?.must_equal true
	    end

	    it "must properly be false" do
		subject.has_rotation?.must_equal false
	    end
	end
    end

    describe "when composing" do
	it "must append a Transformation" do
	    (Composition.new(Transformation.new) + Transformation.new).size.must_equal 2
	end

	it "must merge with a Composition" do
	    (Composition.new(Transformation.new) + Composition.new(Transformation.new)).size.must_equal 2
	end
    end

    describe "when transforming a Point" do
	it "must handle composed translations" do
	    composition = Composition.new(Transformation.new origin:[1,2]) + Composition.new(Transformation.new [3,4])
	    composition.transform(Point[5,6]).must_equal Point[9, 12]
	end
    end
end

Version data entries

15 entries across 15 versions & 3 rubygems

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