Skip to content

Commit ce2df14

Browse files
authored
Basic tests for words_without_punctuation
1 parent 5bc0beb commit ce2df14

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

test/core/string/test_words.rb

+41
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,46 @@
2020
end
2121

2222
end
23+
24+
method :words_without_punctuation do
25+
26+
test do
27+
# English
28+
x = "How?? I don't believe you!!!"
29+
x.words_without_punctuation.assert == ['How', 'I', "don't", 'believe', 'you']
30+
x = 'Slowly, grudgingly he said: "This has to stop."'
31+
x.words_without_punctuation.assert == ['Slowly', 'grudgingly', 'he', 'said', 'This', 'has', 'to', 'stop']
32+
end
33+
34+
test do
35+
# French
36+
x = "« Bonjour ! J'ai rendezvous avec mademoiselle Dupont-Fleury ! »"
37+
x.words_without_punctuation.assert == ['Bonjour', "J'ai", "rendezvous", "avec", "mademoiselle", "Dupont-Fleury"]
38+
end
39+
40+
test do
41+
# Spanish
42+
x = "«¡María, te amo!», exclamó Juan. … «¿Por qué me sigues mintiendo?"
43+
x.words_without_punctuation.assert == ['María', 'te', 'amo', 'exclamó', 'Juan', 'Por', 'qué', 'me', 'sigues', 'mintiendo']
44+
end
45+
46+
test do
47+
# Italian
48+
x = 'Alcune persone scrivono al computer; altre con la penna: io con le due.'
49+
x.words_without_punctuation.assert == ['Alcune', 'persone', 'scrivono', 'al', 'computer', 'altre', 'con', 'la', 'penna', 'io', 'con', 'le', 'due']
50+
end
51+
52+
test do
53+
# German
54+
x = '“chevron,” „französische“ Anführungszeichen'
55+
x.words_without_punctuation.assert == ['chevron', 'französische', 'Anführungszeichen']
56+
end
57+
58+
test do
59+
# Russian
60+
x = '"А ты прав." — сказал он, — "Я великолепен!".'
61+
x.words_without_punctuation.assert == ['А', 'ты', 'прав', 'сказал', 'он', 'Я', 'великолепен']
62+
end
63+
end
2364

2465
end

0 commit comments

Comments
 (0)