From 8ea9d0756cd7c66ee8c6b2c619d9ad8bf067dfa6 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Tue, 5 Feb 2019 16:22:06 -0700 Subject: [PATCH] WIP/BROKEN: handling and testing nested alts --- src/Util.hx | 11 +++++++++-- tests/TestMain.hx | 2 +- tests/UtilTest.hx | 10 ++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 tests/UtilTest.hx diff --git a/src/Util.hx b/src/Util.hx index 49576c9..32ecfe2 100644 --- a/src/Util.hx +++ b/src/Util.hx @@ -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) { 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; } } \ No newline at end of file diff --git a/tests/TestMain.hx b/tests/TestMain.hx index c4a9eb5..9dd1a50 100644 --- a/tests/TestMain.hx +++ b/tests/TestMain.hx @@ -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()]); } } \ No newline at end of file diff --git a/tests/UtilTest.hx b/tests/UtilTest.hx new file mode 100644 index 0000000..9d7b54a --- /dev/null +++ b/tests/UtilTest.hx @@ -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() { + + } +} \ No newline at end of file