From 6cb7fb167adac5109044f57e55274ca92dad2cf0 Mon Sep 17 00:00:00 2001 From: gaborsch Date: Fri, 28 Jun 2024 21:00:17 +0200 Subject: [PATCH] Fixed #60 --- .../arrays/split_delimiters_more.rock | 23 ++++++++++++++++++ .../arrays/split_delimiters_more.rock.out | 13 ++++++++++ rocky.jar | Bin 286587 -> 286597 bytes src/rockstar/statement/SplitStatement.java | 2 +- 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 programs/tests/fixtures/arrays/split_delimiters_more.rock create mode 100644 programs/tests/fixtures/arrays/split_delimiters_more.rock.out diff --git a/programs/tests/fixtures/arrays/split_delimiters_more.rock b/programs/tests/fixtures/arrays/split_delimiters_more.rock new file mode 100644 index 0000000..5886c93 --- /dev/null +++ b/programs/tests/fixtures/arrays/split_delimiters_more.rock @@ -0,0 +1,23 @@ +letters = "ABC" + +split letters into middle with "B" ( -> "A", "C" ) +say middle at 0 +say middle at 1 +say middle at 2 + +split letters into start with "A" ( -> "", "BC" ) +say start at 0 +say start at 1 +say start at 2 + +split letters into end with "C" ( -> "AB" ) ( expected "AB", "") +say end at 0 +say end at 1 +say end at 2 + +split letters into nosep with "" +say nosep at 0 +say nosep at 1 +say nosep at 2 +say nosep at 3 + diff --git a/programs/tests/fixtures/arrays/split_delimiters_more.rock.out b/programs/tests/fixtures/arrays/split_delimiters_more.rock.out new file mode 100644 index 0000000..ad4e665 --- /dev/null +++ b/programs/tests/fixtures/arrays/split_delimiters_more.rock.out @@ -0,0 +1,13 @@ +A +C +mysterious + +BC +mysterious +AB + +mysterious +A +B +C +mysterious diff --git a/rocky.jar b/rocky.jar index 88cdc5e1046f646346f7f92b4799ebda8eb607d9..eb326e00fbf99d28c3e16908ad309956ffaa1a29 100644 GIT binary patch delta 5892 zcmZ8l2RN2(8-AZ*i;S|jh!SNcdqtU*Jwpizl`ZmBN<%|DDQ%LXD7=O26lqY=5JgL$ zii!sD-^2fXf4}44yykgb_jTWoXN=bh?WhytcV14>ye#;WRCtho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1SM-?t?(4t$bGy~2#(dvsGR(~0kG@2d=ct`_<< zGMdEI#LU62zOE@{L zlNrE|+j0Gj8Md5$#gyXV*y`DrHL zQ^=A%3)oZilzg^B4(KDKajGBKD~OTcp<^=Svl!ifpyEVa2NO#c!OA#KM#8E8}h;(0V;EV8tHspbIzG#y= zK02h%X&pEi=pWMoVF*KXp&!Oo=zrkMMTr!TL}) z)F-%GANV8vi9X>oF@X6{&oChR3j@dx`R31seM0+@xo|xYKh7oV^)w_rg@$CEG@tYv z!Y4eHe8R(lhAumb6|RwQ56nyhb~HR-Fxn%LEBh<&pSnM2#8u44-#Q2uUP64z}@ z;w+%wxL)JU>wHZ~$%yl^uZ>!gY?M z?lng;NA>xHCt*HtMgF?^z!RaQ6L3bj*a`AN{-aL72kC=OWc@DAgfGh(cq4o7B$~L8 z`nx9ap$o~=TR_&aeF2GYpG5VAB!1IEvhJG;N&IYA!oSv))VuBq`-FAm-N-(ycO(89 zH?psCi^x7FECR78ZeS7FKNoj`$K63Zvd{1!`w`~>=K|Mt#RIq_Zhx9MvOX38+nd1&F@sKM(rO$EG0Tp636Il5Cv-Ojr5wcH?mLf1uB0hXmx0zdt9W@`Ml%?|pHg5x)SN(xKgmn%9d>mBd6n`lJ zepWLP=WvvN2s+4Sh5)>R`Vd&ng?$nN(5FgPJQOG~=f@fL(KvkRwJ`-ebk+DlD;3AC z4+W+wVz9c>f$UyXS$ryoqxl2zCbl6In5d$lKeP>UW#RkzQCR)Q`Hsl2bzyKd^TOcH zL3&T9&|Wi*xE2)gs$CTq}H-h;qWqqs$n=x8I)t~B4EnuaM&g^ xCLyDiJThvsRpD?&(OA)Cr6Pc|%D=aIEbMp_{6Fu9&VOTVBY?B0lQJ9_=l@hpAA0}* diff --git a/src/rockstar/statement/SplitStatement.java b/src/rockstar/statement/SplitStatement.java index 163be7f..27a53ef 100644 --- a/src/rockstar/statement/SplitStatement.java +++ b/src/rockstar/statement/SplitStatement.java @@ -57,7 +57,7 @@ private List split(String orig, String sep) { int start = 0; int len = orig.length(); - while (start < len) { + while (start < len || (start == len && !emptySep)) { int end = (emptySep ? start + 1 : orig.indexOf(sep, start)); if (end < 0) { end = len;