sanitize « and »

This commit is contained in:
Gwenhael Le Moine 2021-11-09 22:03:39 +01:00
parent ff0aae8ece
commit 26c75346a7
No known key found for this signature in database
GPG key ID: FDFE3669426707A7
2 changed files with 10 additions and 3 deletions

View file

@ -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

View file

@ -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