1
0

Added Formula unit test

This commit is contained in:
cryptogopher 2020-01-24 01:05:59 +01:00
parent 8d0f6eec81
commit ba4c98e213
2 changed files with 29 additions and 0 deletions

View File

@ -79,6 +79,7 @@ module BodyTracking
end
end
class FormulaBuilder < Ripper::SexpBuilder
def initialize(*args)
super(*args)

28
test/unit/formula_test.rb Normal file
View File

@ -0,0 +1,28 @@
require File.expand_path('../../test_helper', __FILE__)
class FormulaTest < ActiveSupport::TestCase
include BodyTracking::Formula
def setup
end
def test_builder_parses_valid_formulas_properly
vector = [
'4', Set[], [
{type: :indexed, content: '4*2'}
],
#'4*2'
#'Fats'
#'fats'
]
vector.each_slice(3) do |formula, identifiers, parts|
parser = FormulaBuilder.new(formula)
i, p = parser.parse
assert_empty parser.errors
assert_equal identifiers, i
assert_equal parts, p
end
end
end