[JS IR BE] Add ranges to runtime, rangeTo for primitive numbers

This commit is contained in:
Svyatoslav Kuzmich
2018-07-03 15:29:33 +03:00
parent 4c38899a2a
commit 1abb4f42ac
93 changed files with 59 additions and 99 deletions
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
// IGNORE_BACKEND: NATIVE
class StrList : List<String?> {
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
class A : Collection<Char> {
override val size: Int
get() = throw UnsupportedOperationException()
-1
View File
@@ -1,2 +1 @@
// IGNORE_BACKEND: JS_IR
fun box() = if (4 as? Unit != null) "Fail" else "OK"
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
class IntRange {
operator fun contains(a: Int) = (1..2).contains(a)
}
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
fun test(str: String): String {
var s = ""
for (i in 1..3) {
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
fun box(): String {
var s = "OK"
for (i in 1..3) {
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
fun box(): String {
var r = ""
for (i in 1..1) {
@@ -1,5 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND: JS_IR
var index = 0
interface IterableIterator : Iterator<Int> {
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
fun box(): String {
val x = 2
return when(x) {
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
class MyRange1() : ClosedRange<Int> {
override val start: Int
get() = 0
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
package demo2
fun print(o : Any?) {}
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
package demo2
fun print(o : Any?) {}
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
fun test() = 239
fun box() = if(test() in 239..240) "OK" else "fail"
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
fun test1(): String {
var r = ""
for (i in 1..2) {
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
//KT-3869 Loops and finally: outer finally block not run
class MyString {
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
//test for appropriate
class MyString {
-1
View File
@@ -1,5 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND: JS_IR
//KT-1038 Cannot compile lazy iterators
class YieldingIterator<T>(val yieldingFunction : ()->T?) : Iterator<T>
@@ -1,5 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND: JS_IR
fun IntRange.forEach(body : (Int) -> Unit) {
for(i in this) {
body(i)
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
fun test1(): Boolean {
test1@ for(i in 1..2) {
continue@test1
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
operator fun Int.component1() = this + 1
operator fun Int.component2() = this + 2
@@ -1,5 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND: JS_IR
operator fun Int.component1() = this + 1
operator fun Int.component2() = this + 2
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
class M {
operator fun Int.component1() = this + 1
operator fun Int.component2() = this + 2
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
class M {
operator fun Int.component1() = this + 1
operator fun Int.component2() = this + 2
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
operator fun Int.component1() = this + 1
operator fun Int.component2() = this + 2
@@ -1,5 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND: JS_IR
operator fun Int.component1() = this + 1
operator fun Int.component2() = this + 2
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
class M {
operator fun Int.component1() = this + 1
operator fun Int.component2() = this + 2
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
class M {
operator fun Int.component1() = this + 1
operator fun Int.component2() = this + 2
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
operator fun Int.component1() = this + 1
operator fun Int.component2() = this + 2
@@ -1,5 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND: JS_IR
operator fun Int.component1() = this + 1
operator fun Int.component2() = this + 2
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
class M {
operator fun Int.component1() = this + 1
operator fun Int.component2() = this + 2
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
class M {
operator fun Int.component1() = this + 1
operator fun Int.component2() = this + 2
-1
View File
@@ -1,5 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND: JS_IR
public abstract class FList<T>() {
public abstract val head: T
public abstract val tail: FList<T>
@@ -1,5 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND: JS_IR
// KT-5869
operator fun <T> Iterator<T>.iterator(): Iterator<T> = this
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
// WITH_RUNTIME
val range = 1 .. 3
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
operator fun IntRange.contains(s: String): Boolean = true
fun box(): String {
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
fun box(): String {
var result = 0
val intRange: IntProgression = 1..3
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
fun box(): String {
var result = 0
val intRange = 1..3
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
fun box(): String {
var result = 0
for (i: Int? in 1..3) {
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
private object EmptyMap : Map<Any, Nothing> {
override val size: Int get() = 0
override fun isEmpty(): Boolean = true
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
private object EmptyStringMap : Map<String, Nothing> {
override val size: Int get() = 0
override fun isEmpty(): Boolean = true
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
// IGNORE_BACKEND: NATIVE
interface Container {
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
// IGNORE_BACKEND: NATIVE
class A : Map<String, String> {
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
// IGNORE_BACKEND: NATIVE
var result = ""
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
open class A1 {
open val size: Int = 56
}
@@ -1,5 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND: JS_IR
// IGNORE_BACKEND: NATIVE
open class A0<E> : MutableList<E> {
@@ -1,5 +1,4 @@
// !LANGUAGE: +VariableDeclarationInWhenSubject
// IGNORE_BACKEND: JS_IR
val x = 1