Skip to content

Commit 117111c

Browse files
author
Patrick Jackson
committed
add comments
1 parent 9a869f8 commit 117111c

File tree

3 files changed

+53
-46
lines changed

3 files changed

+53
-46
lines changed

common/build.gradle

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ kotlin {
1515
js()
1616
jvm()
1717
// iOS commented out b/c appling test to JS & iOS does not work. Comment JS tests for iOS to work
18-
18+
/*
1919
def buildForDevice = project.findProperty("device")?.toBoolean() ?: false
2020
def iosPreset = (buildForDevice) ? presets.iosArm64 : presets.iosX64
2121
fromPreset(iosPreset, 'ios') {
@@ -28,6 +28,7 @@ kotlin {
2828
}
2929
}
3030
}
31+
*/
3132

3233
}
3334
sourceSets {
@@ -62,14 +63,15 @@ kotlin {
6263
implementation kotlin("stdlib-js")
6364
}
6465
}
65-
iosTest {
66-
dependsOn commonTest
67-
}
66+
// iosTest {
67+
// dependsOn commonTest
68+
// }
6869

6970
}
7071

7172
}
7273

74+
/*
7375
7476
task iosTest {
7577
def device = project.findProperty("iosDevice")?.toString() ?: "iPhone 8"
@@ -101,13 +103,14 @@ task copyFramework {
101103
}
102104
}
103105
106+
*/
107+
104108

105109

106110
// workaround for https://youtrack.jetbrains.com/issue/KT-27170
107111
configurations {
108112
compileClasspath
109113
}
110-
/*
111114
//Workaround to copy kotlin libraries so they are visible during testing
112115
def jsLibDir = "$compileKotlinJs.destinationDir/lib"
113116
def jsTestLibDir = "$compileTestKotlinJs.destinationDir/lib"
@@ -152,4 +155,3 @@ task runMocha(type: NodeTask, dependsOn: [installMocha, jsMainClasses, jsTestCla
152155
}
153156
jsTest.dependsOn runMocha
154157

155-
*/
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import kotlin.test.Test
2+
import kotlin.test.fail
3+
4+
typealias Dispatch = (Any) -> Any
5+
typealias GetState = () -> Any
6+
typealias Thunk = (Dispatch, GetState, Any?) -> Any
7+
8+
data class AppState(val string: String)
9+
10+
val dispatch: Dispatch = { }
11+
val getState: GetState = { AppState("myState") }
12+
13+
fun myThunk(dispatch: Dispatch, getState: GetState, arg: Any?) {
14+
println("Inside thunk")
15+
}
16+
17+
18+
fun multiParamFunctionTest(foo: Any) {
19+
if (foo is Function<*>) {
20+
(foo as Thunk)(dispatch, getState, null)
21+
} else {
22+
fail()
23+
}
24+
}
25+
26+
27+
/**
28+
* Demonstrates bug with `is Function<*>. Passes on JVM & Native, fails on JS
29+
*/
30+
class FunctionCheckTest {
31+
32+
33+
@Test
34+
fun passIsCheck() {
35+
if ({ str: String -> } is Function<*>) {
36+
} else {
37+
fail("Function not recognized in `is Function<*>`")
38+
}
39+
}
40+
41+
@Test
42+
fun typeAliasCheck() {
43+
multiParamFunctionTest(::myThunk)
44+
}
45+
}

common/src/test/kotlin/TypealiasTest.kt

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)