Support lazy val in Scala 3

This commit is contained in:
Alexey Andreev 2024-02-22 19:07:55 +01:00
parent 393cd7f807
commit df4e6e04ae
3 changed files with 28 additions and 0 deletions

View File

@ -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"

View File

@ -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 {

View 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)
}
}