JS: move inline test to box tests
This commit is contained in:
+16
@@ -3,6 +3,7 @@
|
||||
* Found at: compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectOnCallSite.1.kt
|
||||
*/
|
||||
|
||||
// FILE: foo.kt
|
||||
package foo
|
||||
|
||||
import test.*
|
||||
@@ -33,3 +34,18 @@ fun box() : String {
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
// FILE: test.kt
|
||||
package test
|
||||
|
||||
abstract class A<R> {
|
||||
abstract fun getO() : R
|
||||
|
||||
abstract fun getK() : R
|
||||
}
|
||||
|
||||
|
||||
inline fun <R> doWork(job: ()-> R) : R {
|
||||
return job()
|
||||
}
|
||||
|
||||
+15
@@ -3,6 +3,7 @@
|
||||
* Found at: compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectOnCallSiteSuperParams.1.kt
|
||||
*/
|
||||
|
||||
// FILE: foo.kt
|
||||
package foo
|
||||
|
||||
import test.*
|
||||
@@ -29,3 +30,17 @@ fun box() : String {
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
// FILE: test.kt
|
||||
package test
|
||||
|
||||
abstract class A<R>(val param: R) {
|
||||
abstract fun getO() : R
|
||||
|
||||
abstract fun getK() : R
|
||||
}
|
||||
|
||||
|
||||
inline fun <R> doWork(job: ()-> R) : R {
|
||||
return job()
|
||||
}
|
||||
+35
-1
@@ -1,9 +1,43 @@
|
||||
/*
|
||||
* Copy of JVM-backend test
|
||||
* Found at: compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectOnDeclarationSite.2.kt
|
||||
* Found at: compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectOnDeclarationSite.1.kt
|
||||
*/
|
||||
|
||||
// FILE: foo.kt
|
||||
package foo
|
||||
|
||||
import test.*
|
||||
|
||||
fun test1(): String {
|
||||
val o = "O"
|
||||
|
||||
val result = doWork ({o}, {"K"}, "GOOD")
|
||||
|
||||
return result.getO() + result.getK() + result.getParam()
|
||||
}
|
||||
|
||||
fun test2() : String {
|
||||
//same names as in object
|
||||
val o1 = "O"
|
||||
val k1 = "K"
|
||||
|
||||
val result = doWorkInConstructor ({o1}, {k1}, "GOOD")
|
||||
|
||||
return result.getO() + result.getK() + result.getParam()
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
val result1 = test1();
|
||||
if (result1 != "OKGOOD") return "fail1 $result1"
|
||||
|
||||
val result2 = test2();
|
||||
if (result2 != "OKGOOD") return "fail2 $result2"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
// FILE: test.kt
|
||||
package test
|
||||
|
||||
|
||||
+35
@@ -3,6 +3,41 @@
|
||||
* Found at: compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectOnDeclarationSiteSuperParams.1.kt
|
||||
*/
|
||||
|
||||
// FILE: foo.kt
|
||||
package foo
|
||||
|
||||
import test.*
|
||||
|
||||
fun test1(): String {
|
||||
val o = "O"
|
||||
|
||||
val result = doWork ({o}, {"K"}, "11")
|
||||
|
||||
return result.getO() + result.getK() + result.param
|
||||
}
|
||||
|
||||
fun test2() : String {
|
||||
//same names as in object
|
||||
val o1 = "O"
|
||||
val k1 = "K"
|
||||
val param = "11"
|
||||
val result = doWorkInConstructor ({o1}, {k1}, {param})
|
||||
|
||||
return result.getO() + result.getK() + result.param
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
val result1 = test1();
|
||||
if (result1 != "OK11") return "fail1 $result1"
|
||||
|
||||
val result2 = test2();
|
||||
if (result2 != "OK11") return "fail2 $result2"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
// FILE: test.kt
|
||||
package test
|
||||
|
||||
|
||||
+113
@@ -3,6 +3,8 @@
|
||||
* Found at: compiler/testData/codegen/boxInline/builders/builders.1.kt
|
||||
*/
|
||||
|
||||
|
||||
// FILE: foo.kt
|
||||
package foo
|
||||
|
||||
fun testAllInline() : String {
|
||||
@@ -175,4 +177,115 @@ fun box(): String {
|
||||
if (expected != testBodyHtmlNoInline()) return "fail 3: ${testBodyHtmlNoInline()}\nbut expected\n${expected} "
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
// FILE: bar.kt
|
||||
package foo
|
||||
|
||||
import java.util.ArrayList
|
||||
import java.util.HashMap
|
||||
|
||||
abstract class Element {
|
||||
abstract fun render(builder: StringBuilder, indent: String)
|
||||
|
||||
override fun toString(): String {
|
||||
val builder = StringBuilder()
|
||||
render(builder, "")
|
||||
return builder.toString()
|
||||
}
|
||||
}
|
||||
|
||||
class TextElement(val text: String) : Element() {
|
||||
override fun render(builder: StringBuilder, indent: String) {
|
||||
builder.append("$indent$text\n")
|
||||
}
|
||||
}
|
||||
|
||||
abstract class Tag(val name: String) : Element() {
|
||||
val children = ArrayList<Element>()
|
||||
val attributes = HashMap<String, String>()
|
||||
|
||||
inline protected fun <T : Element> initTag(tag: T, init: T.() -> Unit): T {
|
||||
tag.init()
|
||||
children.add(tag)
|
||||
return tag
|
||||
}
|
||||
|
||||
override fun render(builder: StringBuilder, indent: String) {
|
||||
builder.append("$indent<$name${renderAttributes()}>\n")
|
||||
for (c in children) {
|
||||
c.render(builder, indent + " ")
|
||||
}
|
||||
builder.append("$indent</$name>\n")
|
||||
}
|
||||
|
||||
private fun renderAttributes(): String? {
|
||||
val builder = StringBuilder()
|
||||
for (a in attributes.keys) {
|
||||
builder.append(" $a=\"${attributes[a]}\"")
|
||||
}
|
||||
return builder.toString()
|
||||
}
|
||||
}
|
||||
|
||||
abstract class TagWithText(name: String) : Tag(name) {
|
||||
operator fun String.unaryPlus() {
|
||||
children.add(TextElement(this))
|
||||
}
|
||||
}
|
||||
|
||||
class HTML() : TagWithText("html") {
|
||||
inline fun head(init: Head.() -> Unit) = initTag(Head(), init)
|
||||
|
||||
inline fun body(init: Body.() -> Unit) = initTag(Body(), init)
|
||||
|
||||
fun bodyNoInline(init: Body.() -> Unit) = initTag(Body(), init)
|
||||
}
|
||||
|
||||
class Head() : TagWithText("head") {
|
||||
inline fun title(init: Title.() -> Unit) = initTag(Title(), init)
|
||||
}
|
||||
|
||||
class Title() : TagWithText("title")
|
||||
|
||||
abstract class BodyTag(name: String) : TagWithText(name) {
|
||||
inline fun b(init: B.() -> Unit) = initTag(B(), init)
|
||||
inline fun p(init: P.() -> Unit) = initTag(P(), init)
|
||||
inline fun pNoInline(init: P.() -> Unit) = initTag(P(), init)
|
||||
inline fun h1(init: H1.() -> Unit) = initTag(H1(), init)
|
||||
inline fun ul(init: UL.() -> Unit) = initTag(UL(), init)
|
||||
inline fun a(href: String, init: A.() -> Unit) {
|
||||
val a = initTag(A(), init)
|
||||
a.href = href
|
||||
}
|
||||
}
|
||||
|
||||
class Body() : BodyTag("body")
|
||||
class UL() : BodyTag("ul") {
|
||||
inline fun li(init: LI.() -> Unit) = initTag(LI(), init)
|
||||
}
|
||||
|
||||
class B() : BodyTag("b")
|
||||
class LI() : BodyTag("li")
|
||||
class P() : BodyTag("p")
|
||||
class H1() : BodyTag("h1")
|
||||
class A() : BodyTag("a") {
|
||||
public var href: String
|
||||
get() = attributes["href"]!!
|
||||
set(value) {
|
||||
attributes["href"] = value
|
||||
}
|
||||
}
|
||||
|
||||
inline fun html(init: HTML.() -> Unit): HTML {
|
||||
val html = HTML()
|
||||
html.init()
|
||||
return html
|
||||
}
|
||||
|
||||
fun htmlNoInline(init: HTML.() -> Unit): HTML {
|
||||
val html = HTML()
|
||||
html.init()
|
||||
return html
|
||||
}
|
||||
+112
@@ -3,6 +3,7 @@
|
||||
* Found at: compiler/testData/codegen/boxInline/builders/buildersAndLambdaCapturing.1.kt
|
||||
*/
|
||||
|
||||
// FILE: foo.kt
|
||||
package foo
|
||||
|
||||
|
||||
@@ -180,4 +181,115 @@ fun box(): String {
|
||||
if (expected != testBodyHtmlNoInline({captured})) return "fail 6: ${testBodyHtmlNoInline({captured})}\nbut expected\n${expected} "
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
// FILE: bar.kt
|
||||
package foo
|
||||
|
||||
import java.util.ArrayList
|
||||
import java.util.HashMap
|
||||
|
||||
abstract class Element {
|
||||
abstract fun render(builder: StringBuilder, indent: String)
|
||||
|
||||
override fun toString(): String {
|
||||
val builder = StringBuilder()
|
||||
render(builder, "")
|
||||
return builder.toString()
|
||||
}
|
||||
}
|
||||
|
||||
class TextElement(val text: String) : Element() {
|
||||
override fun render(builder: StringBuilder, indent: String) {
|
||||
builder.append("$indent$text\n")
|
||||
}
|
||||
}
|
||||
|
||||
abstract class Tag(val name: String) : Element() {
|
||||
val children = ArrayList<Element>()
|
||||
val attributes = HashMap<String, String>()
|
||||
|
||||
inline protected fun <T : Element> initTag(tag: T, init: T.() -> Unit): T {
|
||||
tag.init()
|
||||
children.add(tag)
|
||||
return tag
|
||||
}
|
||||
|
||||
override fun render(builder: StringBuilder, indent: String) {
|
||||
builder.append("$indent<$name${renderAttributes()}>\n")
|
||||
for (c in children) {
|
||||
c.render(builder, indent + " ")
|
||||
}
|
||||
builder.append("$indent</$name>\n")
|
||||
}
|
||||
|
||||
private fun renderAttributes(): String? {
|
||||
val builder = StringBuilder()
|
||||
for (a in attributes.keys) {
|
||||
builder.append(" $a=\"${attributes[a]}\"")
|
||||
}
|
||||
return builder.toString()
|
||||
}
|
||||
}
|
||||
|
||||
abstract class TagWithText(name: String) : Tag(name) {
|
||||
operator fun String.unaryPlus() {
|
||||
children.add(TextElement(this))
|
||||
}
|
||||
}
|
||||
|
||||
class HTML() : TagWithText("html") {
|
||||
inline fun head(init: Head.() -> Unit) = initTag(Head(), init)
|
||||
|
||||
inline fun body(init: Body.() -> Unit) = initTag(Body(), init)
|
||||
|
||||
fun bodyNoInline(init: Body.() -> Unit) = initTag(Body(), init)
|
||||
}
|
||||
|
||||
class Head() : TagWithText("head") {
|
||||
inline fun title(init: Title.() -> Unit) = initTag(Title(), init)
|
||||
}
|
||||
|
||||
class Title() : TagWithText("title")
|
||||
|
||||
abstract class BodyTag(name: String) : TagWithText(name) {
|
||||
inline fun b(init: B.() -> Unit) = initTag(B(), init)
|
||||
inline fun p(init: P.() -> Unit) = initTag(P(), init)
|
||||
fun pNoInline(init: P.() -> Unit) = initTag(P(), init)
|
||||
inline fun h1(init: H1.() -> Unit) = initTag(H1(), init)
|
||||
inline fun ul(init: UL.() -> Unit) = initTag(UL(), init)
|
||||
inline fun a(href: String, init: A.() -> Unit) {
|
||||
val a = initTag(A(), init)
|
||||
a.href = href
|
||||
}
|
||||
}
|
||||
|
||||
class Body() : BodyTag("body")
|
||||
class UL() : BodyTag("ul") {
|
||||
inline fun li(init: LI.() -> Unit) = initTag(LI(), init)
|
||||
}
|
||||
|
||||
class B() : BodyTag("b")
|
||||
class LI() : BodyTag("li")
|
||||
class P() : BodyTag("p")
|
||||
class H1() : BodyTag("h1")
|
||||
class A() : BodyTag("a") {
|
||||
public var href: String
|
||||
get() = attributes["href"]!!
|
||||
set(value) {
|
||||
attributes["href"] = value
|
||||
}
|
||||
}
|
||||
|
||||
inline fun html(init: HTML.() -> Unit): HTML {
|
||||
val html = HTML()
|
||||
html.init()
|
||||
return html
|
||||
}
|
||||
|
||||
fun htmlNoInline(init: HTML.() -> Unit): HTML {
|
||||
val html = HTML()
|
||||
html.init()
|
||||
return html
|
||||
}
|
||||
+16
-1
@@ -3,6 +3,7 @@
|
||||
* Found at: compiler/testData/codegen/boxInline/capture/captureInlinable.1.kt
|
||||
*/
|
||||
|
||||
// FILE: foo.kt
|
||||
package foo
|
||||
|
||||
import test.*
|
||||
@@ -15,4 +16,18 @@ fun box(): String {
|
||||
if (result2 != 12) return "test2: ${result2}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// FILE: test.kt
|
||||
package test
|
||||
|
||||
|
||||
inline fun <R> doWork(crossinline job: ()-> R) : R {
|
||||
return notInline({job()})
|
||||
}
|
||||
|
||||
fun <R> notInline(job: ()-> R) : R {
|
||||
return job()
|
||||
}
|
||||
|
||||
+16
-1
@@ -3,6 +3,7 @@
|
||||
* Found at: compiler/testData/codegen/boxInline/capture/captureInlinableAndOther.1.kt
|
||||
*/
|
||||
|
||||
// FILE: foo.kt
|
||||
package foo
|
||||
|
||||
import test.*
|
||||
@@ -15,4 +16,18 @@ fun box(): String {
|
||||
if (result2 != 12) return "test2: ${result2}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// FILE: test.kt
|
||||
package test
|
||||
|
||||
|
||||
inline fun <R> doWork(crossinline job: ()-> R) : R {
|
||||
val k = 10;
|
||||
return notInline({k; job()})
|
||||
}
|
||||
|
||||
fun <R> notInline(job: ()-> R) : R {
|
||||
return job()
|
||||
}
|
||||
+13
-1
@@ -3,6 +3,7 @@
|
||||
* Found at: compiler/testData/codegen/boxInline/capture/captureThisAndReceiver.1.kt
|
||||
*/
|
||||
|
||||
// FILE: foo.kt
|
||||
package foo
|
||||
|
||||
fun test1() : Int {
|
||||
@@ -32,4 +33,15 @@ fun box(): String {
|
||||
if (test2() != 11) return "test2: ${test2()}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// FILE: bar.kt
|
||||
package foo
|
||||
|
||||
class My(val value: Int)
|
||||
|
||||
inline fun <T, R> T.perform(job: (T)-> R) : R {
|
||||
return job(this)
|
||||
}
|
||||
|
||||
+13
-1
@@ -3,6 +3,7 @@
|
||||
* Found at: compiler/testData/codegen/boxInline/complex/closureChain.1.kt
|
||||
*/
|
||||
|
||||
// FILE: foo.kt
|
||||
package foo
|
||||
|
||||
fun test1(): Int {
|
||||
@@ -14,4 +15,15 @@ fun box(): String {
|
||||
if (test1() != 2) return "test1: ${test1()}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// FILE: bar.kt
|
||||
package foo
|
||||
|
||||
class Inline() {
|
||||
|
||||
inline fun foo(closure1 : (l: Int) -> String, param: Int, closure2: String.() -> Int) : Int {
|
||||
return closure1(param).closure2()
|
||||
}
|
||||
}
|
||||
+14
-1
@@ -3,6 +3,7 @@
|
||||
* Found at: compiler/testData/codegen/boxInline/defaultValues/defaultMethod.1.kt
|
||||
*/
|
||||
|
||||
// FILE: foo.kt
|
||||
package foo
|
||||
|
||||
import test.*
|
||||
@@ -26,4 +27,16 @@ fun box(): String {
|
||||
if (result != "OOKK") return "fail2: ${result}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// FILE: test.kt
|
||||
package test
|
||||
|
||||
inline fun <T> simpleFun(arg: String = "O", lambda: (String) -> T): T {
|
||||
return lambda(arg)
|
||||
}
|
||||
|
||||
inline fun <T> simpleFunR(lambda: (String) -> T, arg: String = "O"): T {
|
||||
return lambda(arg)
|
||||
}
|
||||
+13
@@ -3,6 +3,7 @@
|
||||
* Found at: compiler/testData/codegen/boxInline/capture/generics.1.kt
|
||||
*/
|
||||
|
||||
// FILE: foo.kt
|
||||
package foo
|
||||
|
||||
import test.*
|
||||
@@ -21,4 +22,16 @@ fun box(): String {
|
||||
if (result != "OK1111") return "fail1: ${result}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
// FILE: test.kt
|
||||
package test
|
||||
|
||||
inline fun <T, R> mfun(arg: T, f: (T) -> R) : R {
|
||||
return f(arg)
|
||||
}
|
||||
|
||||
inline fun <T> doSmth(a: T): String {
|
||||
return a.toString()
|
||||
}
|
||||
+9
@@ -3,6 +3,7 @@
|
||||
* Found at: compiler/testData/codegen/boxInline/defaultValues/inlineInDefaultParameter.1.kt
|
||||
*/
|
||||
|
||||
// FILE: foo.kt
|
||||
package foo
|
||||
|
||||
import test.*
|
||||
@@ -29,5 +30,13 @@ fun box(): String {
|
||||
result = testCompilationInline("OKOK")
|
||||
if (result != "OKOK") return "fail4: ${result}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
// FILE: test.kt
|
||||
package test
|
||||
|
||||
inline fun getStringInline(): String {
|
||||
return "OK"
|
||||
}
|
||||
+9
@@ -1,3 +1,12 @@
|
||||
// FILE: a.kt
|
||||
package foo
|
||||
|
||||
inline fun sum(a: Int, b: Int): Int {
|
||||
return a + b
|
||||
}
|
||||
|
||||
|
||||
// FILE: b.kt
|
||||
package foo
|
||||
|
||||
// CHECK_NOT_CALLED: sum
|
||||
+13
@@ -3,6 +3,7 @@
|
||||
* Found at: compiler/testData/codegen/boxInline/lambdaTransformation/lambdaCloning.1.kt
|
||||
*/
|
||||
|
||||
// FILE: foo.kt
|
||||
package foo
|
||||
|
||||
import test.*
|
||||
@@ -23,4 +24,16 @@ fun box(): String {
|
||||
if (result != "11") return "fail2: ${result}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
// FILE: test.kt
|
||||
package test
|
||||
|
||||
inline fun <T> doSmth(a: T) : String {
|
||||
return {a.toString()}()
|
||||
}
|
||||
|
||||
inline fun <T> doSmth2(a: T) : String {
|
||||
return {{a.toString()}()}()
|
||||
}
|
||||
+13
@@ -3,6 +3,7 @@
|
||||
* Found at: compiler/testData/codegen/boxInline/lambdaTransformation/lambdaInLambda2.1.kt
|
||||
*/
|
||||
|
||||
// FILE: foo.kt
|
||||
package foo
|
||||
|
||||
import test.*
|
||||
@@ -25,4 +26,16 @@ fun box(): String {
|
||||
if (test1("nostart") != "fail") return "fail2"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
// FILE: test.kt
|
||||
package test
|
||||
|
||||
inline fun <R> mfun(f: () -> R) {
|
||||
f()
|
||||
}
|
||||
|
||||
fun concat(suffix: String, l: (s: String) -> Unit) {
|
||||
l(suffix)
|
||||
}
|
||||
+18
-1
@@ -3,6 +3,7 @@
|
||||
* Found at: compiler/testData/codegen/boxInline/lambdaTransformation/lambdaInLambdaNoInline.1.kt
|
||||
*/
|
||||
|
||||
// FILE: foo.kt
|
||||
package foo
|
||||
|
||||
import test.*
|
||||
@@ -57,4 +58,20 @@ fun box(): String {
|
||||
if (test22({"start"}) != "start") return "fail5: ${test22({"start"})}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// FILE: test.kt
|
||||
package test
|
||||
|
||||
fun concat(suffix: String, l: (s: String) -> Unit) {
|
||||
l(suffix)
|
||||
}
|
||||
|
||||
fun <T> noInlineFun(arg: T, f: (T) -> Unit) {
|
||||
f(arg)
|
||||
}
|
||||
|
||||
inline fun doSmth(a: String): String {
|
||||
return a.toString()
|
||||
}
|
||||
+11
-1
@@ -3,6 +3,7 @@
|
||||
* Found at: compiler/testData/codegen/boxInline/lambdaTransformation/regeneratedLambdaName.1.kt
|
||||
*/
|
||||
|
||||
// FILE: foo.kt
|
||||
package foo
|
||||
|
||||
import test.*
|
||||
@@ -27,4 +28,13 @@ fun box(): String {
|
||||
if (result2 != 2) return "fail2: ${result2}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// FILE: test.kt
|
||||
package test
|
||||
|
||||
|
||||
inline fun <R> call(crossinline f: () -> R) : R {
|
||||
return {f()} ()
|
||||
}
|
||||
+21
-1
@@ -3,6 +3,7 @@
|
||||
* Found at: compiler/testData/codegen/boxInline/lambdaTransformation/sameCaptured.1.kt
|
||||
*/
|
||||
|
||||
// FILE: foo.kt
|
||||
package foo
|
||||
|
||||
import test.*
|
||||
@@ -26,4 +27,23 @@ fun box(): String {
|
||||
if (testSameCaptured{result += 1111} != "OK") return "test2 : ${testSameCaptured{result = 1111}}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// FILE: test.kt
|
||||
package test
|
||||
|
||||
|
||||
inline fun <R> doWork(crossinline job: ()-> R) : R {
|
||||
val k = 10;
|
||||
return notInline({k; job()})
|
||||
}
|
||||
|
||||
inline fun <R> doWork(crossinline job: ()-> R, crossinline job2: () -> R) : R {
|
||||
val k = 10;
|
||||
return notInline({k; job(); job2()})
|
||||
}
|
||||
|
||||
fun <R> notInline(job: ()-> R) : R {
|
||||
return job()
|
||||
}
|
||||
+13
@@ -3,6 +3,7 @@
|
||||
* Found at: compiler/testData/codegen/boxInline/capture/simpleCapturingInClass.1.kt
|
||||
*/
|
||||
|
||||
// FILE: a.kt
|
||||
package foo
|
||||
|
||||
fun testAll(): String {
|
||||
@@ -74,4 +75,16 @@ fun box(): String {
|
||||
if (testAllWithCapturedVar() != "112.513.514152122.523.52425H262728.5") return "testAllWithCapturedVar: ${testAllWithCapturedVar()}"
|
||||
if (testAllWithCapturedValAndVar() != "112.513.514152122.523.52425H262728.5") return "testAllWithCapturedVal: ${testAllWithCapturedValAndVar()}"
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
// FILE: b.kt
|
||||
package foo
|
||||
|
||||
class InlineAll {
|
||||
|
||||
inline fun inline(s: (Int, Double, Double, String, Long) -> String,
|
||||
a1: Int, a2: Double, a3: Double, a4: String, a5: Long): String {
|
||||
return s(a1, a2, a3, a4, a5)
|
||||
}
|
||||
}
|
||||
+11
-1
@@ -3,6 +3,7 @@
|
||||
* Found at: compiler/testData/codegen/boxInline/capture/simpleCapturingInPackage.1.kt
|
||||
*/
|
||||
|
||||
// FILE: a.kt
|
||||
package foo
|
||||
|
||||
fun testAll(): String {
|
||||
@@ -66,4 +67,13 @@ fun box(): String {
|
||||
if (testAllWithCapturedVar() != "112.513.514152122.523.52425H262728.5") return "testAllWithCapturedVar: ${testAllWithCapturedVar()}"
|
||||
if (testAllWithCapturedValAndVar() != "112.513.514152122.523.52425H262728.5") return "testAllWithCapturedVal: ${testAllWithCapturedValAndVar()}"
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// FILE: b.kt
|
||||
package foo
|
||||
|
||||
inline fun inline(s: (Int, Double, Double, String, Long) -> String,
|
||||
a1: Int, a2: Double, a3: Double, a4: String, a5: Long): String {
|
||||
return s(a1, a2, a3, a4, a5)
|
||||
}
|
||||
+15
-1
@@ -3,6 +3,7 @@
|
||||
* Found at: compiler/testData/codegen/boxInline/defaultValues/simpleDefaultMethod.1.kt
|
||||
*/
|
||||
|
||||
// FILE: foo.kt
|
||||
package foo
|
||||
|
||||
import test.*
|
||||
@@ -26,4 +27,17 @@ fun box(): String {
|
||||
if (result != "OK") return "fail2: ${result}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// FILE: test.kt
|
||||
package test
|
||||
|
||||
inline fun emptyFun(arg: String = "O") {
|
||||
|
||||
}
|
||||
|
||||
inline fun simpleFun(arg: String = "O"): String {
|
||||
val r = arg;
|
||||
return r;
|
||||
}
|
||||
+22
@@ -3,6 +3,7 @@
|
||||
* Found at: compiler/testData/codegen/boxInline/trait/trait.1.kt
|
||||
*/
|
||||
|
||||
// FILE: foo.kt
|
||||
package foo
|
||||
|
||||
import test.*
|
||||
@@ -27,4 +28,25 @@ fun box(): String {
|
||||
if (testClassObject() != "classobject") return "test3: ${testClassObject()}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
// FILE: test.kt
|
||||
package test
|
||||
|
||||
internal interface InlineTrait {
|
||||
|
||||
public fun finalInline(s: () -> String): String {
|
||||
return s()
|
||||
}
|
||||
|
||||
companion object {
|
||||
public inline final fun finalInline(s: () -> String): String {
|
||||
return s()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Z: InlineTrait {
|
||||
|
||||
}
|
||||
+15
-1
@@ -3,6 +3,7 @@
|
||||
* Found at: compiler/testData/codegen/boxInline/tryCatchFinally/tryCatch.1.kt
|
||||
*/
|
||||
|
||||
// FILE: a.kt
|
||||
package foo
|
||||
|
||||
fun test1() : Int {
|
||||
@@ -57,4 +58,17 @@ fun box(): String {
|
||||
if (test2() != -2) return "test2: ${test2()}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
package foo
|
||||
|
||||
class My(val value: Int)
|
||||
|
||||
inline fun <T, R> T.perform(job: (T)-> R) : R {
|
||||
return job(this)
|
||||
}
|
||||
|
||||
inline fun String.toInt2() : Int = parseInt(this)
|
||||
|
||||
class RuntimeExceptionWithValue(val value: String) : RuntimeException()
|
||||
+32
-1
@@ -3,6 +3,7 @@
|
||||
* Found at: compiler/testData/codegen/boxInline/tryCatchFinally/tryCatch2.1.kt
|
||||
*/
|
||||
|
||||
// FILE: a.kt
|
||||
package foo
|
||||
|
||||
fun test1(): Int {
|
||||
@@ -111,4 +112,34 @@ fun box(): String {
|
||||
if (test33() != -3) return "test33: ${test33()}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// FILE: b.kt
|
||||
package foo
|
||||
|
||||
class My(val value: Int)
|
||||
|
||||
inline fun <T, R> T.performWithFail(job: (T)-> R, failJob: (T) -> R): R {
|
||||
try {
|
||||
return job(this)
|
||||
} catch (e: RuntimeExceptionWithValue) {
|
||||
return failJob(this)
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <T, R> T.performWithFail2(job: (T)-> R, failJob: (e: RuntimeExceptionWithValue, T) -> R): R {
|
||||
try {
|
||||
return job(this)
|
||||
} catch (e: RuntimeExceptionWithValue) {
|
||||
return failJob(e, this)
|
||||
}
|
||||
}
|
||||
|
||||
@native object Number {
|
||||
fun parseInt(str: String): Int = noImpl
|
||||
}
|
||||
|
||||
inline fun String.toInt2(): Int = parseInt(this)
|
||||
|
||||
class RuntimeExceptionWithValue(val value: String = "") : RuntimeException()
|
||||
+28
-1
@@ -3,6 +3,7 @@
|
||||
* Found at: compiler/testData/codegen/boxInline/tryCatchFinally/tryCatchFinally.1.kt
|
||||
*/
|
||||
|
||||
// FILE: a.kt
|
||||
package foo
|
||||
|
||||
fun test1(): Int {
|
||||
@@ -77,4 +78,30 @@ fun box(): String {
|
||||
if (test3() != 113) return "test3: ${test3()}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// FILE: b.kt
|
||||
package foo
|
||||
|
||||
class My(val value: Int)
|
||||
|
||||
inline fun <T, R> T.performWithFinally(job: (T)-> R, finallyFun: (T) -> R) : R {
|
||||
try {
|
||||
job(this)
|
||||
} finally {
|
||||
return finallyFun(this)
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <T, R> T.performWithFailFinally(job: (T)-> R, failJob : (e: RuntimeException, T) -> R, finallyFun: (T) -> R) : R {
|
||||
try {
|
||||
job(this)
|
||||
} catch (e: RuntimeException) {
|
||||
failJob(e, this)
|
||||
} finally {
|
||||
return finallyFun(this)
|
||||
}
|
||||
}
|
||||
|
||||
inline fun String.toInt2() : Int = parseInt(this)
|
||||
+29
-5
@@ -1,8 +1,35 @@
|
||||
/*
|
||||
* Copy of JVM-backend test
|
||||
* Found at: compiler/testData/codegen/boxInline/complex/use.2.kt
|
||||
* Found at: compiler/testData/codegen/boxInline/complex/use.1.kt
|
||||
*/
|
||||
|
||||
// FILE: foo.kt
|
||||
package foo
|
||||
|
||||
import test.*
|
||||
|
||||
fun Data.test1(d: Data) : Int {
|
||||
val input2 = Input(this)
|
||||
val input = Input(this)
|
||||
return input.use<Input, Int>{
|
||||
val output = Output(d)
|
||||
output.use<Output,Int>{
|
||||
input.copyTo(output, 10)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
|
||||
val result = Data().test1(Data())
|
||||
if (result != 100) return "test1: ${result}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
// FILE: test.kt
|
||||
package test
|
||||
|
||||
public class Data()
|
||||
@@ -40,7 +67,4 @@ public inline fun <T: Closeable, R> T.use(block: (T)-> R) : R {
|
||||
this.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+34
@@ -3,6 +3,7 @@
|
||||
* Found at: compiler/testData/codegen/boxInline/complex/with.1.kt
|
||||
*/
|
||||
|
||||
// FILE: foo.kt
|
||||
package foo
|
||||
|
||||
import test.*
|
||||
@@ -47,3 +48,36 @@ fun box(): String {
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
// FILE: test.kt
|
||||
package test
|
||||
|
||||
|
||||
public class Data()
|
||||
|
||||
public class Input(val d: Data) : Closeable {
|
||||
public fun data() : Int = 100
|
||||
}
|
||||
public class Output(val d: Data) : Closeable {
|
||||
public fun doOutput(data: Int): Int = data
|
||||
}
|
||||
|
||||
public interface Closeable {
|
||||
open public fun close() {}
|
||||
}
|
||||
|
||||
public inline fun <R> use(block: ()-> R) : R {
|
||||
return block()
|
||||
}
|
||||
|
||||
public fun <R> useNoInline(block: ()-> R) : R {
|
||||
return block()
|
||||
}
|
||||
|
||||
|
||||
public fun Input.copyTo(output: Output, size: Int): Int {
|
||||
return output.doOutput(this.data())
|
||||
}
|
||||
|
||||
public inline fun <T> with2(receiver : T, crossinline body : T.() -> Unit) : Unit = {receiver.body()}()
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user