Remove some conflicting declarations from test, convert code to new Regex API

This commit is contained in:
Ilya Gorbunov
2015-04-12 02:28:58 +03:00
parent 2ae767a049
commit 43dd23bd4b
@@ -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<String> = 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'")