From 43dd23bd4befbb092791b05f34065133fc1c401e Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Sun, 12 Apr 2015 02:28:58 +0300 Subject: [PATCH] Remove some conflicting declarations from test, convert code to new Regex API --- .../reservedWords/_commonFiles/helpers.kt | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/js/js.translator/testData/reservedWords/_commonFiles/helpers.kt b/js/js.translator/testData/reservedWords/_commonFiles/helpers.kt index fe7993fd5b5..02bb57bb238 100644 --- a/js/js.translator/testData/reservedWords/_commonFiles/helpers.kt +++ b/js/js.translator/testData/reservedWords/_commonFiles/helpers.kt @@ -1,25 +1,17 @@ package foo +import kotlin.text.Regex + fun testRenamed(case: String, f: () -> Unit) = test(case, true, f) fun testNotRenamed(case: String, f: () -> Unit) = test(case, false, f) -native -fun String.replace(r: String, s: String): String = noImpl - -native -class RegExp(pattern: String, flag: String) - -native -fun String.match(r: RegExp): Array = noImpl - fun test(keyword: String, expectedRenamed: Boolean, f: Any) { val fs = f.toString().replace("while (false)", "") - val matches = fs.match(RegExp("[\\w$]*$keyword[\\w_$]*", "g")) + val matches = Regex("[\\w$]*$keyword[\\w_$]*").matchAll(fs).map { it.value }.toList() - assertNotEquals(null, matches, "matches == null, fs = $fs") - assertNotEquals(0, matches.size, "matches = $matches") + assertNotEquals(0, matches.size(), "matches is empty for fs = $fs") - val actual = matches[matches.size -1] + val actual = matches.last() assertTrue(actual.contains(keyword), "'$keyword' not found in '$matches' from '$fs'")