Skip to content

Commit

Permalink
Fix minitest deprecation warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
stevegeek committed Oct 19, 2022
1 parent c5a294e commit d5fafe8
Show file tree
Hide file tree
Showing 12 changed files with 213 additions and 213 deletions.
54 changes: 27 additions & 27 deletions test/support/scale_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,94 +16,94 @@ def self.included(base)

describe "#new" do
it "must set attributes" do
subject.value.must_equal(4)
subject.unit.to_s.must_equal('J')
_(subject.value).must_equal(4)
_(subject.unit.to_s).must_equal('J')
end
end

describe "#unit" do
it "must be a unit" do
subject.must_respond_to(:unit)
subject.unit.must_be_instance_of(Unitwise::Unit)
_(subject).must_respond_to(:unit)
_(subject.unit).must_be_instance_of(Unitwise::Unit)
end
end

describe "#root_terms" do
it "must be a collection of terms" do
subject.must_respond_to(:root_terms)
subject.root_terms.must_be_kind_of Enumerable
subject.root_terms.first.must_be_instance_of(Unitwise::Term)
_(subject).must_respond_to(:root_terms)
_(subject.root_terms).must_be_kind_of Enumerable
_(subject.root_terms.first).must_be_instance_of(Unitwise::Term)
end
end

describe "#terms" do
it "must return an array of terms" do
subject.terms.must_be_kind_of(Enumerable)
subject.terms.first.must_be_kind_of(Unitwise::Term)
_(subject.terms).must_be_kind_of(Enumerable)
_(subject.terms.first).must_be_kind_of(Unitwise::Term)
end
end

describe "#atoms" do
it "must return an array of atoms" do
subject.atoms.must_be_kind_of(Enumerable)
subject.atoms.first.must_be_kind_of(Unitwise::Atom)
_(subject.atoms).must_be_kind_of(Enumerable)
_(subject.atoms.first).must_be_kind_of(Unitwise::Atom)
end
end

describe "#scalar" do
it "must return value relative to terminal atoms" do
subject.scalar.must_equal 4000
mph.scalar.must_almost_equal 26.8224
cel.scalar.must_equal 295.15
_(subject.scalar).must_equal 4000
_(mph.scalar).must_almost_equal 26.8224
_(cel.scalar).must_equal 295.15
end
end

describe "#magnitude" do
it "must return the magnitude" do
mph.magnitude.must_equal(60)
cel.magnitude.must_equal(22)
_(mph.magnitude).must_equal(60)
_(cel.magnitude).must_equal(22)
end
end

describe "#special?" do
it "must return true when unit is special, false otherwise" do
subject.special?.must_equal false
cel.special?.must_equal true
_(subject.special?).must_equal false
_(cel.special?).must_equal true
end
end

describe "#depth" do
it "must return a number indicating how far down the rabbit hole goes" do
subject.depth.must_equal 11
k.depth.must_equal 3
_(subject.depth).must_equal 11
_(k.depth).must_equal 3
end
end

describe "#frozen?" do
it "must be frozen" do
subject.frozen?.must_equal true
_(subject.frozen?).must_equal true
end
end

describe "#simplified_value" do
it "must simplify to an Integer" do
result = described_class.new(4.0, 'foot').simplified_value
result.must_equal 4
result.must_be_kind_of(Integer)
_(result).must_equal 4
_(result).must_be_kind_of(Integer)
end

it "must simplify to a Float" do
result = described_class.new(BigDecimal("1.5"), 'foot').simplified_value
result.must_equal 1.5
result.must_be_kind_of(Float)
_(result).must_equal 1.5
_(result).must_be_kind_of(Float)
end
end

describe "#inspect" do
it "must show the unit and value" do
result = described_class.new(12, 'meter').inspect
result.must_include("value=12")
result.must_include("unit=meter")
_(result).must_include("value=12")
_(result).must_include("unit=meter")
end
end
end
Expand Down
66 changes: 33 additions & 33 deletions test/unitwise/atom_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
subject { Unitwise::Atom }
describe "::data" do
it "must have data" do
subject.data.must_be_instance_of Array
subject.data.count.must_be :>, 0
_(subject.data).must_be_instance_of Array
_(subject.data.count).must_be :>, 0
end
end

describe "::all" do
it "must be an Array of instances" do
subject.all.must_be_instance_of Array
subject.all.first.must_be_instance_of Unitwise::Atom
_(subject.all).must_be_instance_of Array
_(subject.all.first).must_be_instance_of Unitwise::Atom
end
end

describe "::find" do
it "must find atoms" do
subject.find("m").must_be_instance_of Unitwise::Atom
subject.find("V").must_be_instance_of Unitwise::Atom
_(subject.find("m")).must_be_instance_of Unitwise::Atom
_(subject.find("V")).must_be_instance_of Unitwise::Atom
end
end

Expand All @@ -31,87 +31,87 @@
let(:joule) { Unitwise::Atom.find("J")}
describe "#scale" do
it "must be nil for base atoms" do
second.scale.must_be_nil
_(second.scale).must_be_nil
end
it "sould be a Scale object for derived atoms" do
yard.scale.must_be_instance_of Unitwise::Scale
_(yard.scale).must_be_instance_of Unitwise::Scale
end
it "must be a FunctionalScale object for special atoms" do
celsius.scale.must_be_instance_of Unitwise::Functional
_(celsius.scale).must_be_instance_of Unitwise::Functional
end
end

describe "#base?" do
it "must be true for base atoms" do
second.base?.must_equal true
_(second.base?).must_equal true
end
it "must be false for derived atoms" do
yard.base?.must_equal false
pi.base?.must_equal false
_(yard.base?).must_equal false
_(pi.base?).must_equal false
end
end

describe "#derived?" do
it "must be false for base atoms" do
second.derived?.must_equal false
_(second.derived?).must_equal false
end
it "must be true for derived atoms" do
yard.derived?.must_equal true
celsius.derived?.must_equal true
_(yard.derived?).must_equal true
_(celsius.derived?).must_equal true
end
end

describe "#metric?" do
it "must be true for base atoms" do
second.metric?.must_equal true
_(second.metric?).must_equal true
end
it "must be false for english atoms" do
yard.metric?.must_equal false
_(yard.metric?).must_equal false
end
end

describe "#special?" do
it "must be true for special atoms" do
celsius.special?.must_equal true
_(celsius.special?).must_equal true
end
it "must be false for non-special atoms" do
second.special?.must_equal false
_(second.special?).must_equal false
end
end

describe "#arbitrary?" do
it "must be true for arbitrary atoms" do
pfu.arbitrary?.must_equal true
_(pfu.arbitrary?).must_equal true
end
it "must be false for non-arbitrary atoms" do
yard.arbitrary?.must_equal false
celsius.arbitrary?.must_equal false
_(yard.arbitrary?).must_equal false
_(celsius.arbitrary?).must_equal false
end
end

describe "#terminal?" do
it "must be true for atoms without a valid measurement atom" do
second.terminal?.must_equal true
pi.terminal?.must_equal true
_(second.terminal?).must_equal true
_(pi.terminal?).must_equal true
end
it "must be false for child atoms" do
yard.terminal?.must_equal false
_(yard.terminal?).must_equal false
end
end

describe "#scalar" do
it "must return scalar relative to terminal atom" do
second.scalar.must_equal 1
yard.scalar.must_almost_equal 0.9144
pi.scalar.must_almost_equal 3.141592653589793
_(second.scalar).must_equal 1
_(yard.scalar).must_almost_equal 0.9144
_(pi.scalar).must_almost_equal 3.141592653589793
end
end

describe "#dim" do
it "must return the dim" do
second.dim.must_equal 'T'
yard.dim.must_equal 'L'
joule.dim.must_equal 'L2.M.T-2'
_(second.dim).must_equal 'T'
_(yard.dim).must_equal 'L'
_(joule.dim).must_equal 'L2.M.T-2'
end
end

Expand All @@ -123,7 +123,7 @@

describe "#frozen?" do
it "should be frozen" do
second.frozen?.must_equal true
_(second.frozen?).must_equal true
end
end

Expand All @@ -139,7 +139,7 @@
}
)

atom.validate!.must_equal true
_(atom.validate!).must_equal true
end

it "returns an error for an atom with missing properties" do
Expand Down
20 changes: 10 additions & 10 deletions test/unitwise/expression/decomposer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,40 @@
describe "#terms" do
it "should accept codes" do
fts = subject.new("[ft_i]/s").terms
fts.count.must_equal 2
_(fts.count).must_equal 2
end
it "should accept names" do
kms = subject.new("kilometer/second").terms
kms.count.must_equal 2
_(kms.count).must_equal 2
end
it "should accept spaced names" do
ncg = subject.new("Newtonian constant of gravitation").terms
ncg.count.must_equal 1
_(ncg.count).must_equal 1
end
it "should accept parameterized names" do
pc = subject.new("planck_constant").terms
pc.count.must_equal 1
_(pc.count).must_equal 1
end
it "should accept symbols" do
saff = subject.new("<i>g<sub>n</sub></i>").terms
saff.count.must_equal 1
_(saff.count).must_equal 1
end
it "should accept complex units" do
complex = subject.new("(mg.(km/s)3/J)2.Pa").terms
complex.count.must_equal 5
_(complex.count).must_equal 5
end
it "should accept more complex units" do
complex = subject.new("4.1(mm/2s3)4.7.3J-2").terms
complex.count.must_equal 3
_(complex.count).must_equal 3
end
it "should accept weird units" do
frequency = subject.new("/s").terms
frequency.count.must_equal 1
_(frequency.count).must_equal 1
end
it "should accept units with a factor and unit" do
oddity = subject.new("2ms2").terms
oddity.count.must_equal 1
_(oddity.count).must_equal 1
end
end

end
end
16 changes: 8 additions & 8 deletions test/unitwise/expression/matcher_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,39 @@
describe "::atom(:codes)" do
subject { Unitwise::Expression::Matcher.atom(:primary_code)}
it "must be an Alternative list" do
subject.must_be_instance_of Parslet::Atoms::Alternative
_(subject).must_be_instance_of Parslet::Atoms::Alternative
end
it "must parse [in_i]" do
subject.parse("[in_i]").must_equal("[in_i]")
_(subject.parse("[in_i]")).must_equal("[in_i]")
end
end
describe "::metric_atom(:names)" do
subject { Unitwise::Expression::Matcher.metric_atom(:names)}
it "must be an Alternative list of names" do
subject.must_be_instance_of Parslet::Atoms::Alternative
_(subject).must_be_instance_of Parslet::Atoms::Alternative
end
it "must parse 'joule'" do
subject.parse('joule').must_equal('joule')
_(subject.parse('joule')).must_equal('joule')
end
end

describe "::atom(:slugs)" do
subject { Unitwise::Expression::Matcher.atom(:slugs)}
it "must be an Alternative list of slugs" do
subject.must_be_instance_of Parslet::Atoms::Alternative
_(subject).must_be_instance_of Parslet::Atoms::Alternative
end
it "must match 'georgian_year'" do
subject.parse("mean_gregorian_year").must_equal("mean_gregorian_year")
_(subject.parse("mean_gregorian_year")).must_equal("mean_gregorian_year")
end
end

describe "::prefix(:symbol)" do
subject { Unitwise::Expression::Matcher.prefix(:symbol)}
it "must be an Alternative list of symbols" do
subject.must_be_instance_of Parslet::Atoms::Alternative
_(subject).must_be_instance_of Parslet::Atoms::Alternative
end
it "must parse 'h'" do
subject.parse('h').must_equal('h')
_(subject.parse('h')).must_equal('h')
end
end
end
Loading

0 comments on commit d5fafe8

Please sign in to comment.