File tree Expand file tree Collapse file tree 1 file changed +68
-0
lines changed
src/test/kotlin/com/compiler/server Expand file tree Collapse file tree 1 file changed +68
-0
lines changed Original file line number Diff line number Diff line change
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
+
You can’t perform that action at this time.
0 commit comments