JS/RTTI. Fix build and tests
This commit is contained in:
committed by
Alexey Andreev
parent
9bb60b48b2
commit
3a87049359
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package java.lang
|
||||
|
||||
@library
|
||||
@@ -27,7 +43,7 @@ public class NumberFormatException(message: String? = null) : RuntimeException(m
|
||||
@library
|
||||
public class NullPointerException(message: String? = null) : RuntimeException(message) {}
|
||||
|
||||
library
|
||||
@library
|
||||
public class ClassCastException(message: String? = null) : RuntimeException(message) {}
|
||||
|
||||
@library
|
||||
|
||||
@@ -217,7 +217,7 @@ private fun RegExp.findNext(input: String, from: Int): MatchResult? {
|
||||
get() {
|
||||
if (groupValues_ == null) {
|
||||
groupValues_ = object : java.util.AbstractList<String>() {
|
||||
override val size: Int get() = match.size
|
||||
override val size: Int get() = match.length
|
||||
override fun get(index: Int): String = match[index] ?: ""
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -45,6 +45,6 @@ public fun RegExp.reset() {
|
||||
public val input: String
|
||||
public val length: Int
|
||||
|
||||
nativeGetter
|
||||
public fun get(index: Int): String?
|
||||
@nativeGetter
|
||||
public operator fun get(index: Int): String?
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -54,13 +54,13 @@ class RegExpTest {
|
||||
@test fun regExpExec() {
|
||||
val string = "R2D2 beats A5D5 "
|
||||
var re = RegExp("""(\w\d)(\w\d)""", "g")
|
||||
val m1: Array<out String?> = re.exec(string)!!
|
||||
assertEquals(arrayOf("R2D2", "R2", "D2"), m1)
|
||||
val m1 = re.exec(string)!!
|
||||
assertEquals(arrayOf("R2D2", "R2", "D2"), m1.toArray())
|
||||
assertEquals(0, m1.index)
|
||||
assertEquals(4, re.lastIndex)
|
||||
|
||||
val m2: Array<out String?> = re.exec(string)!!
|
||||
assertEquals(arrayOf("A5D5", "A5", "D5"), m2)
|
||||
val m2 = re.exec(string)!!
|
||||
assertEquals(arrayOf("A5D5", "A5", "D5"), m2.toArray())
|
||||
assertEquals(string.indexOf(m2[0]!!), m2.index)
|
||||
|
||||
val noMatch = re.exec(string)
|
||||
@@ -68,4 +68,9 @@ class RegExpTest {
|
||||
assertEquals(0, re.lastIndex)
|
||||
}
|
||||
|
||||
fun RegExpMatch.toArray(): Array<out String?> {
|
||||
val array = arrayOfNulls<String>(length)
|
||||
array.indices.forEach { array[it] = this[it] }
|
||||
return array
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user