Skip to content

Commit e2c8a65

Browse files
committed
chore(release): add kotlin 1.8.0
1 parent 8f8bf13 commit e2c8a65

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package com.compiler.server
2+
3+
import com.compiler.server.base.BaseExecutorTest
4+
import org.junit.jupiter.api.Test
5+
6+
class KotlinFeatureSince180 : BaseExecutorTest() {
7+
8+
@Test
9+
fun `stable cbrt() function`() {
10+
run(
11+
code = """
12+
import kotlin.math.*
13+
14+
fun main() {
15+
val num = 27
16+
val negNum = -num
17+
18+
println("The cube root of ${"$"}{num.toDouble()} is: " + cbrt(num.toDouble()))
19+
}
20+
""".trimIndent(),
21+
contains = "The cube root of 27.0 is: 3.0"
22+
)
23+
}
24+
25+
@Test
26+
fun `stable cbrt() function for negative values`() {
27+
run(
28+
code = """
29+
import kotlin.math.*
30+
31+
fun main() {
32+
val num = 27
33+
val negNum = -num
34+
35+
println("The cube root of ${"$"}{negNum.toDouble()} is: " + cbrt(negNum.toDouble()))
36+
}
37+
""".trimIndent(),
38+
contains = "The cube root of -27.0 is: -3.0"
39+
)
40+
}
41+
42+
@Test
43+
fun `calculate the time difference between multiple TimeMarks`() {
44+
run(
45+
code = """
46+
import kotlin.time.*
47+
48+
@OptIn(ExperimentalTime::class)
49+
fun main() {
50+
val timeSource = TimeSource.Monotonic
51+
val mark1 = timeSource.markNow()
52+
Thread.sleep(500) // Sleep 0.5 seconds.
53+
val mark2 = timeSource.markNow()
54+
55+
repeat(4) { n ->
56+
val mark3 = timeSource.markNow()
57+
val elapsed1 = mark3 - mark1
58+
val elapsed2 = mark3 - mark2
59+
60+
println(mark2 > mark1)
61+
}
62+
}
63+
""".trimIndent(),
64+
contains = "true"
65+
)
66+
}
67+
}
68+

0 commit comments

Comments
 (0)