mirror of
https://github.com/konsoletyper/teavm.git
synced 2024-11-21 01:00:54 +08:00
Support lazy val in Scala 3
This commit is contained in:
parent
393cd7f807
commit
df4e6e04ae
@ -9,6 +9,7 @@ idea = "2020.1.4"
|
||||
idea-scala = "2020.1.43"
|
||||
maven = "3.5.4"
|
||||
maven-tools = "3.7.1"
|
||||
scala = "3.4.0"
|
||||
|
||||
|
||||
[libraries]
|
||||
@ -47,6 +48,8 @@ maven-core = { module = "org.apache.maven:maven-core", version.ref = "maven" }
|
||||
maven-embedder = { module = "org.apache.maven:maven-embedder", version.ref = "maven" }
|
||||
maven-compat = { module = "org.apache.maven:maven-compat", version.ref = "maven" }
|
||||
|
||||
scala-library = { module = "org.scala-lang:scala3-library_3", version.ref = "scala" }
|
||||
|
||||
[libraries.maven-plugin-tools-api]
|
||||
module = "org.apache.maven.plugin-tools:maven-plugin-tools-api"
|
||||
version.ref = "maven-tools"
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
plugins {
|
||||
`java-library`
|
||||
scala
|
||||
}
|
||||
|
||||
description = "Tests"
|
||||
@ -43,6 +44,7 @@ dependencies {
|
||||
testImplementation(libs.rhino)
|
||||
testImplementation(libs.junit)
|
||||
testImplementation(libs.testng)
|
||||
testImplementation(libs.scala.library)
|
||||
}
|
||||
|
||||
tasks.test {
|
||||
|
23
tests/src/test/scala/org/teavm/scala/LazyValueTest.scala
Normal file
23
tests/src/test/scala/org/teavm/scala/LazyValueTest.scala
Normal file
@ -0,0 +1,23 @@
|
||||
package org.teavm.scala
|
||||
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.teavm.junit.TeaVMTestRunner
|
||||
import org.junit.Assert.assertEquals
|
||||
|
||||
@RunWith(classOf[TeaVMTestRunner])
|
||||
class LazyValueTest {
|
||||
private var value: Int = 0
|
||||
|
||||
private lazy val lazyValue: Int = {
|
||||
value += 1
|
||||
23
|
||||
}
|
||||
|
||||
@Test
|
||||
def lazyValueSupport(): Unit = {
|
||||
assertEquals(0, value)
|
||||
assertEquals(23, lazyValue)
|
||||
assertEquals(1, value)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user