Skip to content

Commit

Permalink
Basic tests for words_without_punctuation
Browse files Browse the repository at this point in the history
  • Loading branch information
Sprachprofi authored Aug 28, 2018
1 parent 5bc0beb commit ce2df14
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/core/string/test_words.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,46 @@
end

end

method :words_without_punctuation do

test do
# English
x = "How?? I don't believe you!!!"
x.words_without_punctuation.assert == ['How', 'I', "don't", 'believe', 'you']
x = 'Slowly, grudgingly he said: "This has to stop."'
x.words_without_punctuation.assert == ['Slowly', 'grudgingly', 'he', 'said', 'This', 'has', 'to', 'stop']
end

test do
# French
x = "« Bonjour ! J'ai rendezvous avec mademoiselle Dupont-Fleury ! »"
x.words_without_punctuation.assert == ['Bonjour', "J'ai", "rendezvous", "avec", "mademoiselle", "Dupont-Fleury"]
end

test do
# Spanish
x = "«¡María, te amo!», exclamó Juan. … «¿Por qué me sigues mintiendo?"
x.words_without_punctuation.assert == ['María', 'te', 'amo', 'exclamó', 'Juan', 'Por', 'qué', 'me', 'sigues', 'mintiendo']
end

test do
# Italian
x = 'Alcune persone scrivono al computer; altre con la penna: io con le due.'
x.words_without_punctuation.assert == ['Alcune', 'persone', 'scrivono', 'al', 'computer', 'altre', 'con', 'la', 'penna', 'io', 'con', 'le', 'due']
end

test do
# German
x = '“chevron,” „französische“ Anführungszeichen'
x.words_without_punctuation.assert == ['chevron', 'französische', 'Anführungszeichen']
end

test do
# Russian
x = '"А ты прав." — сказал он, — "Я великолепен!".'
x.words_without_punctuation.assert == ['А', 'ты', 'прав', 'сказал', 'он', 'Я', 'великолепен']
end
end

end

0 comments on commit ce2df14

Please sign in to comment.