Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
radeusgd committed Aug 1, 2022
1 parent c7e85c1 commit b46ae97
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,6 @@ Text.repeat self count=1 =
"Hello World!".take (Range 3 5) == "lo"
"Hello World!".take (Range 5 Nothing) == " World!"
"Hello World!".take (Range 5 12) == " World!"
"Hello World!".take (Range 12 12) == ""
"Hello World!".take (Range 6 12 2) == "Wrd"
"Hello World!".take (Every 2 first=6) == "Wrd"
"Hello World!".take (Every 3) == "Hl Wl"
Expand Down Expand Up @@ -1134,7 +1133,6 @@ Text.take self range =
"Hello World!".drop (Range 3 5) == "Hel World!"
"Hello World!".drop (Range 5 Nothing) == "Hello"
"Hello World!".drop (Range 5 12) == "Hello"
"Hello World!".drop (Range 12 12) == "Hello World!"
"Hello World!".drop (Range 6 12 2) == "Hello ol!"
"Hello World!".drop (Every 2 first=6) == "Hello ol!"
"Hello World!".drop (Every 3) == "elo ord!"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ find_codepoint_ranges text subrange =
Every step start ->
if step <= 0 then Error.throw (Illegal_Argument_Error "Step within Every must be positive.") else
len = text.length
if start >= len then [] else
if start >= len then Range 0 0 else
range = Range start text.length step
find_codepoint_ranges text (By_Index range)
Range _ _ _ ->
Expand Down Expand Up @@ -242,4 +242,3 @@ normalize_range range length =
Panic.throw (Index_Out_Of_Bounds_Error range.start length)
if range.end >= length then Range range.start length range.step else
range

7 changes: 1 addition & 6 deletions test/Tests/src/Data/Text_Spec.enso
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ spec =
"Hello World!".take (While c->c!="z") . should_equal "Hello World!"
"Hello World!".take (Range 3 5) . should_equal "lo"
"Hello World!".take (Range 5 12) . should_equal " World!"
"Hello World!".take (Range 12 12) . should_equal ""
"Hello World!".take (Range 6 12 2) . should_equal "Wrd"
"Hello World!".take (Every 2 first=6) . should_equal "Wrd"
"Hello World!".take (Every 3) . should_equal "HlWl"
Expand All @@ -380,7 +379,7 @@ spec =
txt.take (By_Index [0, Range 14 15, 1]) . should_fail_with Index_Out_Of_Bounds_Error
txt.take (By_Index [0, 1, Range 6 100]) . should_equal "HeWorld!"
txt.take (By_Index [0, 1, Range 6 100 2]) . should_equal "HeWrd"
txt.take (Range 13 12) . should_equal ""
txt.take (Range 13 12) . should_fail_with Index_Out_Of_Bounds_Error
"".take (Range 0 0) . should_fail_with Index_Out_Of_Bounds_Error
"".take (By_Index 0) . should_fail_with Index_Out_Of_Bounds_Error
"ABC".take (By_Index 3) . should_fail_with Index_Out_Of_Bounds_Error
Expand Down Expand Up @@ -417,7 +416,6 @@ spec =
txt_2.take (While c->c!='e') . should_equal txt_2
txt_2.take (Range 3 5) . should_equal 'lo\u{308}'
txt_2.take (Range 5 12) . should_equal ' Wo\u{308}rld!'
txt_2.take (Range 12 12) . should_equal ''

Test.specify "take should work on emojis" <|
'✨🚀🚧😍😃😎😙😉☺'.take First . should_equal '✨'
Expand Down Expand Up @@ -448,7 +446,6 @@ spec =

"".take (While _->True) . should_equal ""

"".take (Range 0 0) . should_equal ""
'ABC\u{301}'.take (Range 0 0) . should_equal ""

'ABC\u{301}'.take (After "") . should_equal 'ABC\u{301}'
Expand Down Expand Up @@ -488,7 +485,6 @@ spec =
"Hello World!".drop (While c->c!="z") . should_equal ""
"Hello World!".drop (Range 3 5) . should_equal "Hel World!"
"Hello World!".drop (Range 5 12) . should_equal "Hello"
"Hello World!".drop (Range 12 12) . should_equal "Hello World!"
"Hello World!".drop (Range 6 12 2) . should_equal "Hello ol!"
"Hello World!".drop (Every 2 first=6) . should_equal "Hello ol!"
"Hello World!".drop (Every 3) . should_equal "elo ord!"
Expand Down Expand Up @@ -541,7 +537,6 @@ spec =
txt_2.drop (While c->c!='e') . should_equal ''
txt_2.drop (Range 3 5) . should_equal 'He\u{302}l Wo\u{308}rld!'
txt_2.drop (Range 5 12) . should_equal 'He\u{302}llo\u{308}'
txt_2.drop (Range 12 12) . should_equal txt_2

Test.specify "drop should work on emojis" <|
'✨🚀🚧😍😃😎😙😉☺'.drop First . should_equal '🚀🚧😍😃😎😙😉☺'
Expand Down

0 comments on commit b46ae97

Please sign in to comment.