WIP/BROKEN: handling and testing nested alts

This commit is contained in:
2019-02-05 16:22:06 -07:00
parent 9d2089238f
commit 8ea9d0756c
3 changed files with 20 additions and 3 deletions

View File

@@ -65,10 +65,17 @@ class Util {
return false;
}
/**
Strip whichever of the given prefix list comes first at the start of a string
**/
public static function stripPrefixes(str: String, prefixes: Array<String>) {
for (prefix in prefixes) {
str = StringTools.replace(str, prefix, '');
if (str.indexOf(prefix) == 0) {
str = StringTools.replace(str, prefix, '');
return StringTools.trim(str);
}
}
return StringTools.trim(str);
return str;
}
}

View File

@@ -3,6 +3,6 @@ import utest.Test;
class TestMain extends Test {
public static function main() {
utest.UTest.run([new AltTest(), new StoryTest()]);
utest.UTest.run([new AltTest(), new StoryTest(), new UtilTest()]);
}
}

10
tests/UtilTest.hx Normal file
View File

@@ -0,0 +1,10 @@
package tests;
import utest.Test;
class UtilTest extends Test {
var exampleStr1 = "here is a string {with enclosures {all nested} {up in it}}";
public function testNestedEnclosure1() {
}
}