Added Formula unit test
This commit is contained in:
parent
8d0f6eec81
commit
ba4c98e213
@ -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
28
test/unit/formula_test.rb
Normal 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
|
Reference in New Issue
Block a user