From a60090045c3e3f7b6748fd1ff063da6e432a2009 Mon Sep 17 00:00:00 2001 From: Omkar Moghe Date: Sun, 7 Apr 2024 18:28:12 -0700 Subject: [PATCH] cleanup --- test/correctness/test_elo.rb | 26 ++++++++++++++++-------- test/correctness/test_logical_methods.rb | 2 ++ test/correctness/test_parsing.rb | 2 ++ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/test/correctness/test_elo.rb b/test/correctness/test_elo.rb index c2b86c3..2bf37c0 100644 --- a/test/correctness/test_elo.rb +++ b/test/correctness/test_elo.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class TestElo < Minitest::Test def setup @env = PortableExpressions::Environment.new( @@ -9,7 +11,7 @@ def setup ) end - def test_elo + def test_elo # rubocop:disable Metrics/AbcSize,Metrics/MethodLength # starting ratings of 2 players rating_a = PortableExpressions::Variable.new("rating_a") rating_b = PortableExpressions::Variable.new("rating_b") @@ -37,20 +39,26 @@ def test_elo def test_elo_no_local_variables rating_a_new = @env.evaluate( # starting ratings of 2 players - PortableExpressions::Expression.new(:-, PortableExpressions::Variable.new("rating_b"), PortableExpressions::Variable.new("rating_a"), output: "rating_difference"), - PortableExpressions::Expression.new(:/, PortableExpressions::Variable.new("rating_difference"), PortableExpressions::Variable.new("scale_factor"), output: "exponent"), + PortableExpressions::Expression.new(:-, PortableExpressions::Variable.new("rating_b"), + PortableExpressions::Variable.new("rating_a"), output: "rating_difference"), + PortableExpressions::Expression.new(:/, PortableExpressions::Variable.new("rating_difference"), + PortableExpressions::Variable.new("scale_factor"), output: "exponent"), PortableExpressions::Expression.new( :+, PortableExpressions::Scalar.new(1), - PortableExpressions::Expression.new(:**, PortableExpressions::Scalar.new(10), PortableExpressions::Variable.new("exponent")), + PortableExpressions::Expression.new(:**, PortableExpressions::Scalar.new(10), + PortableExpressions::Variable.new("exponent")), output: "denominator" ), - PortableExpressions::Expression.new(:/, PortableExpressions::Scalar.new(1), PortableExpressions::Variable.new("denominator"), output: "expected_probability_a"), - + PortableExpressions::Expression.new(:/, PortableExpressions::Scalar.new(1), + PortableExpressions::Variable.new("denominator"), output: "expected_probability_a"), # [0, 1] where 0 is loss, 1 is win, 0.5 is draw - PortableExpressions::Expression.new(:-, PortableExpressions::Variable.new("score_a"), PortableExpressions::Variable.new("expected_probability_a"), output: "k_multiplier"), - PortableExpressions::Expression.new(:*, PortableExpressions::Variable.new("k_factor"), PortableExpressions::Variable.new("k_multiplier"), output: "rating_delta"), - PortableExpressions::Expression.new(:+, PortableExpressions::Variable.new("rating_a"), PortableExpressions::Variable.new("rating_delta"), output: "rating_a_new") + PortableExpressions::Expression.new(:-, PortableExpressions::Variable.new("score_a"), + PortableExpressions::Variable.new("expected_probability_a"), output: "k_multiplier"), + PortableExpressions::Expression.new(:*, PortableExpressions::Variable.new("k_factor"), + PortableExpressions::Variable.new("k_multiplier"), output: "rating_delta"), + PortableExpressions::Expression.new(:+, PortableExpressions::Variable.new("rating_a"), + PortableExpressions::Variable.new("rating_delta"), output: "rating_a_new") ) assert_equal(1016.0, rating_a_new) diff --git a/test/correctness/test_logical_methods.rb b/test/correctness/test_logical_methods.rb index b3ea068..4f8f2ed 100644 --- a/test/correctness/test_logical_methods.rb +++ b/test/correctness/test_logical_methods.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class TestLogicalMethods < Minitest::Test def setup @env = PortableExpressions::Environment.new( diff --git a/test/correctness/test_parsing.rb b/test/correctness/test_parsing.rb index 1feddb8..6d4a309 100644 --- a/test/correctness/test_parsing.rb +++ b/test/correctness/test_parsing.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class TestParser < Minitest::Test def test_variable json = <<~JSON