diff --git a/CHANGELOG b/CHANGELOG index 5ed33879..e50aba3a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,13 +1,16 @@ v2.6.15 added guard against running 'watch' in top level directories, rescue error -when processing-3.0 is specified, and suggest updating to JRubyArt +* when processing-3.0 is specified, and suggest updating to JRubyArt update to +* jruby-complete-1.7.22 (this may be the final release of 1.7.XX series) +* features deprecation of processing map in favor of p5map (or map1d) which +* are now both jruby extensions, along with lerp and norm -v2.6.14 revert to using 'require to load jars' because everything just worked -* before, and sometimes just doesn't with java classpath loading. +v2.6.14 revert to using 'require to load jars' because everything just worked +* before, and sometimes just doesn't with java classpath loading. * jruby-9.0.0.0 has been fixed, so now we don't need compability changes... * use pry-java for live mode v2.6.13 update to jruby-complete-1.7.21 -* the perfomance of 1.7.** series still exceeds jruby-9.0.0.0 +* the perfomance of 1.7.XX series still exceeds jruby-9.0.0.0 v2.6.12 Changes to make jruby and PApplet use same classloader * to make ruby-processing compatible with JRuby-9.0.0.0.rc1+ diff --git a/README.md b/README.md index f5605ce6..a184d874 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ To install jruby-complete use our built in tool (relies on `wget` to download [j since ruby-processing-2.5.0 `rp5 setup install` (was `install_jruby_complete`) -If you haven't got `wget` just download jruby-complete-1.7.21 (for ruby-processing-2.6.14) to the vendors folder (then run above tool) +If you haven't got `wget` just download jruby-complete-1.7.22 (for ruby-processing-2.6.15) to the vendors folder (then run above tool) The vendored jruby-complete is only required for application export, and running certain sketches (eg shader sketches see [wiki][]). diff --git a/Rakefile b/Rakefile index 7eafa1ea..c0920dcc 100644 --- a/Rakefile +++ b/Rakefile @@ -42,6 +42,13 @@ task :test do ruby "test/rp5_test.rb" end +desc 'Spec' +task :spec do + Dir['./spec/processing/*.rb'].each do |sp| + sh "jruby -S rspec #{sp}" + end +end + desc 'Clean' task :clean do Dir['./**/*.%w{jar gem}'].each do |path| diff --git a/ext/monkstone/ColorUtil.java b/ext/monkstone/ColorUtil.java index f69a39da..2a38181e 100644 --- a/ext/monkstone/ColorUtil.java +++ b/ext/monkstone/ColorUtil.java @@ -1,7 +1,12 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. +/** + * The purpose of this uilit is to allow ruby-processing users to use an alternative + * to processing.org color their sketches (to cope with ruby FixNumber vs java int) + * Copyright (C) 2015 Martin Prout. This tool is free software; you can + * redistribute it and/or modify it under the terms of the GNU Lesser General + * Public License as published by the Free Software Foundation; either version + * 2.1 of the License, or (at your option) any later version. + * + * Obtain a copy of the license at http://www.gnu.org/licenses/lgpl-2.1.html */ package monkstone; diff --git a/lib/ruby-processing/helper_methods.rb b/lib/ruby-processing/helper_methods.rb index 26b3bf37..abf14395 100644 --- a/lib/ruby-processing/helper_methods.rb +++ b/lib/ruby-processing/helper_methods.rb @@ -1,8 +1,10 @@ # processing module wrapper require_relative '../rpextras' + module Processing # Provides some convenience methods available in vanilla processing + Java::Monkstone::MathToolLibrary.new.load(JRuby.runtime, false) module HelperMethods # processings epsilon may not be defined yet EPSILON ||= 1.0e-04 @@ -59,40 +61,7 @@ def thread(&block) def map(value, start1, stop1, start2, stop2) start2 + (stop2 - start2) * ((value - start1).to_f / (stop1 - start1)) end - - # ruby alternative implementation of map using range parameters - # (begin..end) and excluded end (begin...end) produce the same result - def map1d(val, r_in, r_out) - r_out.begin + (r_out.end - r_out.begin) * - ((val - r_in.begin).to_f / (r_in.end - r_in.begin)) - end - - # Explicitly provides 'processing.org' map instance method, where - # value is mapped from range 1 to range 2 where values are clamped to - # range 2. - # @param val input - # @param [r_in] start1, stop1 - # @param [r_out] start2, stop2 - # @return mapped value - def constrained_map(val, r_in, r_out) - unless r_in.include? val - return r_out.begin if (val < r_in.begin && r_in.begin < r_in.end) || - (val > r_in.begin && r_in.begin > r_in.end) - return r_out.end - end - r_out.begin + (r_out.end - r_out.begin) * - ((val - r_in.begin).to_f / (r_in.end - r_in.begin)) - end - - # explicitly provide 'processing.org' norm instance method - def norm(value, start, stop) - (value - start).to_f / (stop - start) - end - - # explicitly provide 'processing.org' lerp instance method - def lerp(start, stop, amt) - start + (stop - start) * amt - end + # deprecate :map, :p5map, 2015, 12 # explicitly provide 'processing.org' min instance method # to return a float:- a, b and c need to be floats diff --git a/ruby-processing.gemspec b/ruby-processing.gemspec index 2e94f9cb..f0cdc683 100644 --- a/ruby-processing.gemspec +++ b/ruby-processing.gemspec @@ -13,7 +13,7 @@ Gem::Specification.new do |spec| spec.email = "jeremy@ashkenas.com" spec.description = <<-EOS Ruby-Processing is a ruby wrapper for the processing-2.0 art framework. - This version supports processing-2.2.1, and uses jruby-complete-1.7.XX or an + This version supports processing-2.2.1, and uses jruby-complete-1.7.22 or an installed jruby as the glue between ruby and java. Use both processing libraries and ruby gems in your sketches. The "watch" mode, provides a nice REPL-ish way to work on your processing sketches. @@ -31,10 +31,11 @@ Gem::Specification.new do |spec| spec.require_paths = ["lib"] spec.required_ruby_version = '>= 1.9.3' - spec.add_development_dependency "bundler", "~> 1.3" - spec.add_development_dependency "rake", "~> 10.3" + spec.add_development_dependency "bundler", "~> 1.10" + spec.add_development_dependency "rake", "~> 10.4" spec.add_development_dependency "rake-compiler", "~> 0.9" - spec.add_development_dependency "minitest", "~> 5.3" + spec.add_development_dependency "minitest", "~> 5.8" + spec.add_development_dependency "rspec", "~> 3.3" spec.requirements << 'A decent graphics card' spec.requirements << 'java runtime >= 1.7+' spec.requirements << 'processing = 2.2.1' diff --git a/spec/arc_spec.rb b/spec/arc_spec.rb deleted file mode 100644 index da70e6b2..00000000 --- a/spec/arc_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require_relative '../lib/core' -require_relative '../lib/rpextras' - -Java::MonkstoneArcball::ArcballLibrary.new.load(JRuby.runtime, false) - -describe 'arcball new' do - it 'should give error' do - expect { Processing::ArcBall.init }.to raise_error(ArgumentError) - end -end - -describe 'arcball center and radius' do - let(:applet) { Java::ProcessingCore::PApplet.new } - it 'center and radius pass' do - Processing::ArcBall.init(applet, 200, 100, 50) - end -end - -describe 'arcball center' do - let(:applet) { Java::ProcessingCore::PApplet.new } - it 'center pass' do - Processing::ArcBall.init(applet, 200, 100) - end -end - -############################## -# Failed to mock camera version -############################### diff --git a/spec/deglut_spec.rb b/spec/deglut_spec.rb deleted file mode 100644 index ce4bbb85..00000000 --- a/spec/deglut_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require_relative '../lib/rpextras' - -Java::MonkstoneFastmath::DeglutLibrary.new.load(JRuby.runtime, false) - -EPSILON = 1.0e-04 -TO_RADIAN = Math::PI / 180 - -describe '#DegLut.sin(-720 .. 720) test' do - (-720..720).step(1) do |deg| - it "should work #{deg}" do - sine = DegLut.sin(deg) - expect(sine).to be_within(EPSILON).of(Math.sin(deg * TO_RADIAN)) - end - end -end - -describe '#DegLut.cos(-720 .. 720) test' do - (-720..720).step(1) do |deg| - it "should work #{deg}" do - cosine = DegLut.cos(deg) - expect(cosine).to be_within(EPSILON).of(Math.cos(deg * TO_RADIAN)) - end - end -end diff --git a/spec/helper_methods_spec.rb b/spec/helper_methods_spec.rb deleted file mode 100644 index b8df5dc8..00000000 --- a/spec/helper_methods_spec.rb +++ /dev/null @@ -1,134 +0,0 @@ -require_relative '../lib/ruby-processing/helper_methods' - -include Processing::HelperMethods - -EPSILON = 1.0e-04 - -describe 'dodgy String color' do - it 'should raise TypeError' do - hexstring = '*56666' - expect {hex_color(hexstring)}.to raise_error(StandardError, 'Dodgy Hexstring') - end -end - -describe 'hexadecimal Fixnum color' do - it 'should return color(hex)' do - hexcolor = 0xFFCC6600 - expect(hex_color(hexcolor)).to eq -3381760 - end -end - -describe 'hexadecimal String color' do - it 'should return color(hex_string)' do - hexstring = '#CC6600' - expect(hex_color(hexstring)).to eq -3381760 - end -end - -describe 'double color' do - it 'should return color(double)' do - col_double = 0.5 - expect(hex_color(col_double)).to eq 0.5 - end -end - -describe 'constrained_map included' do - it 'should return constrained_map(x, range1, range2)' do - x = 0 - range1 = (0..10) - range2 = (100..1) - expect(constrained_map(x, range1, range2)).to eq 100 - end -end - -describe 'constrained_map reverse' do - it 'should return constrained_map(x, range1, range2)' do - x0 = 10.1 - x1 = -2 - range1 = (0..10) - range2 = (100..1) - expect(constrained_map(x0, range1, range2)).to eq 1 - expect(constrained_map(x1, range1, range2)).to eq 100 - end -end - -describe 'constrained_map forward' do - it 'should return constrained_map(x, range1, range2)' do - x0 = 10.1 - x1 = -2 - range1 = (0..10) - range2 = (1..100) - expect(constrained_map(x0, range1, range2)).to eq 100 - expect(constrained_map(x1, range1, range2)).to eq 1 - end -end - -describe '2D#dist' do - it 'should return dist(ax, ay, ab, ay)' do - ax, ay, bx, by = 0, 0, 1.0, 1.0 - expect(dist(ax, ay, bx, by)).to eq Math.sqrt(2) - end -end - -describe '2D#dist' do - it 'should return dist(ax, ay, ab, ay)' do - ax, ay, bx, by = 0, 0, 1.0, 0.0 - expect(dist(ax, ay, bx, by)).to eq 1.0 - end -end - -describe '2D#dist' do - it 'should return dist(ax, ay, ab, ay)' do - ax, ay, bx, by = 0, 0, 0.0, 0.0 - expect(dist(ax, ay, bx, by)).to eq 0.0 - end -end - -describe '2D#dist' do - it 'should return dist(ax, ay, ab, ay)' do - ax, ay, bx, by = 1, 1, -2.0, -3.0 - expect(dist(ax, ay, bx, by)).to eq 5 - end -end - -describe '3D#dist' do - it 'should return dist(ax, ay, ab, ay)' do - ax, ay, bx, by, cx, cy = -1, -1, 100, 2.0, 3.0, 100 - expect(dist(ax, ay, bx, by, cx, cy)).to eq 5 - end -end - -describe '3D#dist' do - it 'should return dist(ax, ay, az, bx, by, bz)' do - ax, ay, bx, by, cx, cy = 0, 0, -1.0, -1.0, 0, 0 - expect(dist(ax, ay, bx, by, cx, cy)).to eq Math.sqrt(2) - end -end - -describe '3D#dist' do - it 'should return dist(ax, ay, az, bx, by, bz)' do - ax, ay, bx, by, cx, cy = -1, -1, 0.0, 2.0, 3.0, 0 - expect(dist(ax, ay, bx, by, cx, cy)).to eq 5 - end -end - -describe '3D#dist' do - it 'should return dist(ax, ay, az, bx, by, bz)' do - ax, ay, bx, by, cx, cy = 0, 0, 0.0, 0.0, 0, 0 - expect(dist(ax, ay, bx, by, cx, cy)).to eq 0.0 - end -end - -describe '3D#dist' do - it 'should return dist(ax, ay, az, bx, by, bz)' do - ax, ay, bx, by, cx, cy = 0, 0, 1.0, 0.0, 0, 0 - expect(dist(ax, ay, bx, by, cx, cy)).to eq 1.0 - end -end - -describe '3D#dist' do - it 'should return dist(ax, ay, az, bx, by, bz)' do - ax, ay, bx, by, cx, cy = 0, 0, 1.0, 1.0, 0, 0 - expect(dist(ax, ay, bx, by, cx, cy)).to eq Math.sqrt(2) - end -end diff --git a/spec/let_spec.rb b/spec/let_spec.rb deleted file mode 100644 index 9748838b..00000000 --- a/spec/let_spec.rb +++ /dev/null @@ -1,13 +0,0 @@ -$count = 0 -RSpec.describe "let" do - let(:count) { $count += 1 } - - it "memoizes the value" do - expect(count).to eq(1) - expect(count).to eq(1) - end - - it "is not cached across examples" do - expect(count).to eq(2) - end -end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index dbc4f1a7..dae3870c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,17 +1,99 @@ +require 'pp' # This file was generated by the `rspec --init` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. -# Require this file using `require "spec_helper"` to ensure that it is only -# loaded once. +# The generated `.rspec` file contains `--require spec_helper` which will cause +# this file to always be loaded, without a need to explicitly require it in any +# files. +# +# Given that it is always loaded, you are encouraged to keep this file as +# light-weight as possible. Requiring heavyweight dependencies from this file +# will add to the boot time of your test suite on EVERY test run, even for an +# individual file that may not need all of that loaded. Instead, consider making +# a separate helper file that requires the additional dependencies and performs +# the additional setup, and require it from the spec files that actually need +# it. +# +# The `.rspec` file also contains a few flags that are not defaults but that +# users commonly want. # # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config| - config.treat_symbols_as_metadata_keys_with_true_values = true - config.run_all_when_everything_filtered = true + # rspec-expectations config goes here. You can use an alternate + # assertion/expectation library such as wrong or the stdlib/minitest + # assertions if you prefer. + config.expect_with :rspec do |expectations| + config.backtrace_exclusion_patterns << /sun\.reflect/ + config.backtrace_exclusion_patterns << /org\.jruby/ + # This option will default to `true` in RSpec 4. It makes the `description` + # and `failure_message` of custom matchers include text for helper methods + # defined using `chain`, e.g.: + # be_bigger_than(2).and_smaller_than(4).description + # # => "be bigger than 2 and smaller than 4" + # ...rather than: + # # => "be bigger than 2" + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. This is generally recommended, and will default to + # `true` in RSpec 4. + mocks.verify_partial_doubles = true + end + +# The settings below are suggested to provide a good initial experience +# with RSpec, but feel free to customize to your heart's content. +=begin + # These two settings work together to allow you to limit a spec run + # to individual examples or groups you care about by tagging them with + # `:focus` metadata. When nothing is tagged with `:focus`, all examples + # get run. config.filter_run :focus + config.run_all_when_everything_filtered = true + + # Allows RSpec to persist some state between runs in order to support + # the `--only-failures` and `--next-failure` CLI options. We recommend + # you configure your source control system to ignore this file. + config.example_status_persistence_file_path = "spec/examples.txt" + + # Limits the available syntax to the non-monkey patched syntax that is + # recommended. For more details, see: + # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax + # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ + # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching + config.disable_monkey_patching! + + # This setting enables warnings. It's recommended, but in some cases may + # be too noisy due to issues in dependencies. + config.warnings = true + + # Many RSpec users commonly either run the entire suite or an individual + # file, and it's useful to allow more verbose output when running an + # individual spec file. + if config.files_to_run.one? + # Use the documentation formatter for detailed output, + # unless a formatter has already been configured + # (e.g. via a command-line flag). + config.default_formatter = 'doc' + end + + # Print the 10 slowest examples and example groups at the + # end of the spec run, to help surface which specs are running + # particularly slow. + config.profile_examples = 10 # Run specs in random order to surface order dependencies. If you find an # order dependency and want to debug it, you can fix the order by providing # the seed, which is printed after each run. # --seed 1234 - config.order = 'random' + config.order = :random + + # Seed global randomization in this process using the `--seed` CLI option. + # Setting this allows you to use `--seed` to deterministically reproduce + # test failures related to randomization by passing the same `--seed` value + # as the one that triggered the failure. + Kernel.srand config.seed +=end end diff --git a/spec/vecmath_spec.rb b/spec/vecmath_spec.rb deleted file mode 100644 index ad546116..00000000 --- a/spec/vecmath_spec.rb +++ /dev/null @@ -1,456 +0,0 @@ -require_relative '../lib/rpextras' - -Java::MonkstoneVecmathVec2::Vec2Library.new.load(JRuby.runtime, false) -Java::MonkstoneVecmathVec3::Vec3Library.new.load(JRuby.runtime, false) - -EPSILON = 1.0e-04 - -describe 'Vec2D#to_a' do - it 'should return x, y as an array' do - x, y = 1.0000001, 1.01 - a = Vec2D.new(x, y) - expect(a.to_a).to eq([x, y]) - end -end - -describe 'Vec2D#copy' do - it 'should return a deep copy' do - x, y = 1.0000001, 1.01 - a = Vec2D.new(x, y) - expect(a.copy.to_a).to eq([x, y]) - end -end - -describe 'Vec2D#copy' do - it 'should return a deep copy' do - x, y = 1.0000001, 1.01 - a = Vec2D.new(x, y) - b = a.copy - b *= 0 - expect(a.to_a).not_to eq(b.to_a) - end -end - -describe 'Vec2D#==' do - it 'should return a == b' do - a = Vec2D.new(3, 5) - b = Vec2D.new(6, 7) - expect(a == b).to eq(false) - end -end - -describe 'Vec2D#==' do - it 'should return a == b' do - a = Vec2D.new(3.0000000, 5.00000) - b = Vec2D.new(3.0000000, 5.000001) - expect(a == b).to eq(true) - end -end - -describe 'Vec2D#+' do - it 'should return Vec2D sum of a + b' do - a = Vec2D.new(3, 5) - b = Vec2D.new(6, 7) - expect(a + b).to eq Vec2D.new(9, 12) - end -end - -describe 'Vec2D#-' do - it 'should return Vec2D sum of a - b' do - a = Vec2D.new(3, 5) - b = Vec2D.new(6, 7) - expect(a - b).to eq Vec2D.new(-3, -2) - end -end - - -describe 'Vec2D#*' do - it 'should return Vec2D sum of a * b' do - a = Vec2D.new(3, 5) - b = 2 - expect(a * b).to eq Vec2D.new(6, 10) - end -end - -describe 'Vec2D#from_angle' do - it 'should return Vec2D.from_angle' do - a = Vec2D.from_angle(Math::PI / 4.0) - expect(a).to eq Vec2D.new(Math.sqrt(0.5), Math.sqrt(0.5)) - end -end - -describe 'Vec2D#from_angle' do - it 'should return Vec2D.from_angle' do - a = Vec2D.from_angle(Math::PI * 0.75) - expect(a).to eq Vec2D.new(-1 * Math.sqrt(0.5), Math.sqrt(0.5)) - end -end - -describe 'Vec2D2#x=' do - it 'should set x to supplied value' do - a = Vec2D.new(3, 5) - a.x=23 - expect(a.x).to eq 23.0 - end -end - -describe 'Vec2D mag' do - it 'should return Vec2D mag' do - a = Vec2D.new(-3, -4) - expect(a.mag).to eq 5 - end -end - -describe 'Vec2D mag' do - it 'should return Vec2D mag' do - a = Vec2D.new(3.0, 2) - expect(a.mag).to be_within(EPSILON).of(Math.sqrt(3.0**2 + 2**2)) - end -end - -describe 'Vec2D mag' do - it 'should return Vec2D dist' do - a = Vec2D.new(3, 4) - expect(a.mag).to eq(5) - end -end - -describe 'Vec2D mag' do - it 'should return Vec2D dist' do - a = Vec2D.new(-1, 0) - expect(a.mag).to eq(1) - end -end - - -describe 'Vec2D lerp' do - it 'should return Vec2D lerp' do - a = Vec2D.new(1, 1) - b = Vec2D.new(3, 3) - expect(a.lerp(b, 0.5)).to eq Vec2D.new(2, 2) - end -end - -describe 'Vec2D lerp' do - it 'should return Vec2D lerp' do - a = Vec2D.new(1, 1) - b = Vec2D.new(3, 3) - expect(a.lerp(b, 5)).to eq Vec2D.new(11, 11) - end -end - -describe 'Vec2D lerp!' do - it 'should return Vec2D lerp!' do - a = Vec2D.new(1, 1) - b = Vec2D.new(3, 3) - a.lerp!(b, 0.5) - expect(a).to eq Vec2D.new(2, 2) - end -end - -describe 'Vec2D lerp!' do - it 'should return Vec2D lerp!' do - a = Vec2D.new(1, 1) - b = Vec2D.new(3, 3) - a.lerp!(b, -0.5) - expect(a).to eq Vec2D.new(0, 0) - end -end - -describe 'Vec2D#set_mag' do - it 'should return Vec2D#set_mag' do - a = Vec2D.new(1, 1) - expect(a.set_mag(Math.sqrt(32))).to eq Vec2D.new(4, 4) - end -end - -describe 'Vec2D#set_mag_block_false' do - it 'should return Vec2D#set_mag' do - a = Vec2D.new(1, 1) - expect(a.set_mag(Math.sqrt(32)) { false }).to eq Vec2D.new(1, 1) - end -end - -describe 'Vec2D#set_mag_block_true' do - it 'sho uld return Vec2D#set_mag' do - a = Vec2D.new(1, 1) - expect(a.set_mag(Math.sqrt(32)) { true }).to eq Vec2D.new(4, 4) - end -end - -describe 'Vec2D dist' do - it 'should return a.dist(b)' do - a = Vec2D.new(3, 5) - b = Vec2D.new(6, 7) - expect(a.dist(b)).to eq Math.sqrt(3.0**2 + 2**2) - end -end - - -describe 'Vec2D dot' do - it 'should return Vec2D dist(a, b)' do - a = Vec2D.new(3, 5) - b = Vec2D.new(6, 7) - expect(a.dot(b)).to eq 53 - end -end - -describe 'Vec2D #/' do - it 'should return Vec2D sum of a * b' do - a = Vec2D.new(6, 10) - b = 2 - expect(a / b).to eq Vec2D.new(3, 5) - end -end - -describe 'Vec2D #+=' do - it 'should return Vec2D result of a += b' do - a = Vec2D.new(3, 5) - b = Vec2D.new(6, 7) - a += b - expect(a).to eq Vec2D.new(9, 12) - end -end - -describe 'Vec2D#normalize' do - it 'should return Vec2D#normalize a new Vec2D with mag 1.0' do - a = Vec2D.new(3, 5) - b = a.normalize - expect(b.mag).to be_within(EPSILON).of(1.0) - end -end - -describe 'Vec2D#normalize!' do - it 'should return Vec2D#normalize! Vec2D#mag == 1.0' do - a = Vec2D.new(3, 5) - a.normalize! - expect(a.mag).to be_within(EPSILON).of(1.0) - end -end - -describe 'Vec2D#heading' do - it 'should return Vec2D#heading in radians' do - a = Vec2D.new(1, 1) - expect(a.heading).to be_within(EPSILON).of(Math::PI / 4.0) - end -end - -describe 'Vec2D#inspect' do - it 'should return a String' do - a = Vec2D.new(3, 2.000000000000001) - expect(a.inspect).to eq 'Vec2D(x = 3.0000, y = 2.0000)' - end -end - -describe 'Vec2D#to_a' do - it 'should return x, y as an array' do - x, y = 1.0000001, 1.01 - a = Vec2D.new(x, y) - expect(a.to_a).to eq([x, y]) - end -end - -describe 'Vec2D#array.reduce' do - it 'should correctly sum objects of Vec2D' do - array = [Vec2D.new(1, 2), Vec2D.new(10, 2), Vec2D.new(1, 2)] - sum = array.reduce(Vec2D.new) { |c, d| c + d } - expect(sum).to eq(Vec2D.new(12, 6)) - end -end - -describe 'Vec2D#array.zip(Vec2D#array)' do - it 'should correctly zip arrays of Vec2D' do - one = [Vec2D.new(1, 2), Vec2D.new(10, 2), Vec2D.new(1, 2)] - two = [Vec2D.new(1, 2), Vec2D.new(10, 2), Vec2D.new(1, 2)] - zipped = one.zip(two).flatten - puts zipped - expect(zipped).to eq([Vec2D.new(1, 2), Vec2D.new(1, 2), Vec2D.new(10, 2), Vec2D.new(10, 2), Vec2D.new(1, 2), Vec2D.new(1, 2)]) - end -end - -describe 'Vec2D#rotate rot' do - it 'should return a rotated vector with same mag' do - x, y = 20, 10 - b = Vec2D.new(x, y) - a = b.rotate(Math::PI / 2) - expect(a).to eq(Vec2D.new(-10.0, 20.0)) - end -end - -describe 'Vec3D#to_a' do - it 'should return x, y, z as an array' do - x, y, z = 1.0000001, 1.01, 0.999999 - a = Vec3D.new(x, y, z) - expect(a.to_a).to eq([x, y, z]) - end -end - -describe 'Vec3D#copy' do - it 'should return a deep copy' do - x, y, z = 1.0000001, 1.01, 0.999999 - a = Vec3D.new(x, y, z) - expect(a.copy.to_a).to eq([x, y, z]) - end -end - -describe 'Vec3D#copy' do - it 'should produce a new object' do - x, y, z = 1.0000001, 1.01, 0.999999 - a = Vec3D.new(x, y, z) - b = a.copy - b.normalize! - expect(a).not_to eq(b) - end -end - -describe 'Vec3D#normalize! zero vector' do - it 'should do nothing' do - a = Vec3D.new - b = a.normalize! - expect(a).to eq(b) - end -end - -describe 'Vec3D#normalize zero vector' do - it 'should do nothing' do - a = Vec3D.new - b = a.normalize - expect(a).to eq(b) - expect(a).to_not equal(b) - end -end - -describe 'Vec3D#dist_squared' do - it 'should return Vec3D.dist_squared(a, b)' do - a = Vec3D.new(3, 5, 2) - b = Vec3D.new(6, 7, 1) - expect(a.dist_squared(b)).to eq 3.0**2 + 2**2 + 1 - end -end - -describe 'Vec3D#dist' do - it 'should return Vec3D.dist(a, b)' do - a = Vec3D.new(3, 5, 2) - b = Vec3D.new(6, 7, 1) - expect(a.dist(b)).to eq Math.sqrt(3.0**2 + 2**2 + 1) - end -end - -describe 'Vec3D#normalize' do - it 'should return Vec3D#normalize a new Vec3D with mag == 1.0' do - a = Vec3D.new(3, 5, 2) - b = a.normalize - expect(b.mag).to be_within(EPSILON).of(1.0) - end -end - -describe 'Vec3D#normalize!' do - it 'should return Vec3D#normalize! Vec3D#mag == 1.0' do - a = Vec3D.new(3, 5, 2) - a.normalize! - expect(a.mag).to be_within(EPSILON).of(1.0) - end -end - -describe 'Vec3D#set_mag zero vector' do - it 'should return zero vector' do - a = Vec3D.new(0, 0, 0) - expect(a.set_mag(Math.sqrt(48))).to eq Vec3D.new(0, 0, 0) - end -end - -describe 'Vec3D#set_mag' do - it 'should return Vec3D#set_mag' do - a = Vec3D.new(1, 1, 1) - expect(a.set_mag(Math.sqrt(48))).to eq Vec3D.new(4, 4, 4) - end -end - -describe 'Vec3D#cross product' do - it 'should return Vec3D.cross(vec)' do - a = Vec3D.new(3, 5, 2) - b = Vec3D.new(6, 7, 1) - expect(a.cross(b)).to eq Vec3D.new(-9.0, 9.0, -9.0) - end -end - -describe 'Vec3D#set_mag negative block' do - it 'should return Vec3D#set_mag' do - a = Vec3D.new(1, 1, 1) - expect(a.set_mag(Math.sqrt(48)) { false }).to eq a - end -end - -describe 'Vec3D#inspect' do - it 'should return a String' do - a = Vec3D.new(3, 5, 2.000000000000001) - expect(a.inspect).to eq 'Vec3D(x = 3.0000, y = 5.0000, z = 2.0000)' - end -end - -describe 'Vec3D#set_mag positive block' do - it 'should return Vec3D#set_mag' do - a = Vec3D.new(1, 1, 1) - expect(a.set_mag(Math.sqrt(48)) { true }).to eq Vec3D.new(4, 4, 4) - end -end - -describe 'Vec3D#to_a' do - it 'should return x, y as an array' do - x, y, z = 1.0000001, 1.01, 1.001 - a = Vec3D.new(x, y, z) - expect(a.to_a).to eq([x, y, z]) - end -end - -describe 'Vec3D#z=' do - it 'should set z value' do - x, y, z = 1.0000001, 1.01, 1.001 - a = Vec3D.new(x, y, z) - w = 56.0 - a.z = w - expect(a.z).to eq w - end -end - -describe 'Vec3D#==' do - it 'should return a == b' do - a = Vec3D.new(3.0, 5.0, 0) - b = Vec3D.new(3.0, 5.000001, 0) - expect(a == b).to be true - end -end - -describe 'Vec3D#eql?' do - it 'should return a.eql? b' do - a = Vec3D.new(3.0, 5.0, 0) - b = Vec3D.new(3.0, 5.0, 0) - expect(a.eql?(b)).to be true - end -end - -describe 'Vec3D#eql?' do - it 'should return a.eql? b' do - a = Vec3D.new(3.0, 5.0, 0) - b = Vec3D.new(3.0, 5.000001, 0) - expect(a.eql?(b)).to be false - end -end - -describe 'Vec3D#equal?' do - it 'should return a.eql? b' do - a = Vec3D.new(3.0, 5.0) - expect(a.equal?(a)).to be true - end -end - -describe 'Vec3D#equal?' do - it 'should return a.eql? b' do - a = Vec3D.new(3.0, 5.0, 0) - b = Vec3D.new(3.0, 5.0, 0) - expect(a.equal?(b)).to be false - end -end - - - diff --git a/vendors/Rakefile b/vendors/Rakefile index 024a4d45..e7a30b38 100644 --- a/vendors/Rakefile +++ b/vendors/Rakefile @@ -8,7 +8,7 @@ WARNING = <<-EOS EOS -JRUBYC_VERSION = '1.7.21' +JRUBYC_VERSION = '1.7.22' EXAMPLES = '1.7' HOME_DIR = ENV['HOME'] MAC_OR_LINUX = /linux|mac|darwin/ =~ RbConfig::CONFIG['host_os'] @@ -27,7 +27,7 @@ file "jruby-complete-#{JRUBYC_VERSION}.jar" do rescue warn(WARNING) end - check_sha1("jruby-complete-#{JRUBYC_VERSION}.jar", "e061b9f399a5e8d5cfcca84d4a6baf879111e83c") + check_sha1("jruby-complete-#{JRUBYC_VERSION}.jar", "42dc9be2f706774c24ef61ec2981d05e2c79a9e2") end directory "../lib/ruby"