sanitize « and »
This commit is contained in:
parent
ff0aae8ece
commit
26c75346a7
2 changed files with 10 additions and 3 deletions
|
@ -10,8 +10,12 @@ module Rpn
|
|||
false
|
||||
end
|
||||
|
||||
def sanitize_input( input )
|
||||
input.gsub( '«', ' « ').gsub( '»', ' » ')
|
||||
end
|
||||
|
||||
def parse_input( input )
|
||||
splitted_input = input.split(' ')
|
||||
splitted_input = sanitize_input( input ).split(' ')
|
||||
parsed_tree = []
|
||||
|
||||
opened_programs = 0
|
||||
|
|
|
@ -40,10 +40,13 @@ class TestParser < Test::Unit::TestCase
|
|||
assert_equal [{ value: '« test »', type: :program }], result
|
||||
|
||||
result = Rpn::Parser.new.parse_input( '«test »' )
|
||||
assert_equal [{ value: '«test »', type: :program }], result
|
||||
assert_equal [{ value: '« test »', type: :program }], result
|
||||
|
||||
result = Rpn::Parser.new.parse_input( '« test»' )
|
||||
assert_equal [{ value: '« test»', type: :program }], result
|
||||
assert_equal [{ value: '« test »', type: :program }], result
|
||||
|
||||
result = Rpn::Parser.new.parse_input( '«test»' )
|
||||
assert_equal [{ value: '« test »', type: :program }], result
|
||||
|
||||
result = Rpn::Parser.new.parse_input( '« test test »' )
|
||||
assert_equal [{ value: '« test test »', type: :program }], result
|
||||
|
|
Loading…
Reference in a new issue