Compare commits
No commits in common. "862486e0e8b503b119fdb60fb25d9f4a40691600" and "6539b9deffb4df612a8c72a7558292903ff5c12c" have entirely different histories.
862486e0e8
...
6539b9deff
@ -1,33 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2026 Sergey S. Chernov
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
import kotlinx.coroutines.test.runTest
|
|
||||||
import net.sergeych.lyng.eval
|
|
||||||
import kotlin.test.Test
|
|
||||||
|
|
||||||
class StdlibWasmSmokeTest {
|
|
||||||
@Test
|
|
||||||
fun stdlibIterableExtensionsSmoke() = runTest {
|
|
||||||
eval(
|
|
||||||
"""
|
|
||||||
assertEquals(6, [1,2,3].sum())
|
|
||||||
assertEquals([2,4,6], [1,2,3].map { it * 2 })
|
|
||||||
assertEquals([1,2,2,3,3,4], [1,2,3].flatMap { [it, it+1] })
|
|
||||||
""".trimIndent()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2026 Sergey S. Chernov
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.sergeych.lyng
|
|
||||||
|
|
||||||
import kotlinx.coroutines.test.runTest
|
|
||||||
import net.sergeych.lyng.miniast.BuiltinDocRegistry
|
|
||||||
import net.sergeych.lyng.stdlib_included.rootLyng
|
|
||||||
import kotlin.test.Test
|
|
||||||
import kotlin.test.assertTrue
|
|
||||||
|
|
||||||
class StdlibExtensionWrapperCoverageTest {
|
|
||||||
@Test
|
|
||||||
fun stdlibExtensionWrappersPresent() = runTest {
|
|
||||||
val src = rootLyng
|
|
||||||
val classNames = LinkedHashSet<String>()
|
|
||||||
val classRe = Regex(
|
|
||||||
"^\\s*(?:(?:abstract|override|closed|private|protected|static|open|extern)\\s+)*(?:fun|val|var)\\s+([A-Za-z_][A-Za-z0-9_]*)\\.",
|
|
||||||
RegexOption.MULTILINE
|
|
||||||
)
|
|
||||||
classRe.findAll(src).forEach { m ->
|
|
||||||
val name = m.groupValues.getOrNull(1)?.trim()
|
|
||||||
if (!name.isNullOrEmpty()) classNames.add(name)
|
|
||||||
}
|
|
||||||
|
|
||||||
val scope = Script.newScope()
|
|
||||||
val missing = mutableListOf<String>()
|
|
||||||
for (className in classNames) {
|
|
||||||
val members = BuiltinDocRegistry.extensionMemberNamesFor(className)
|
|
||||||
for (member in members) {
|
|
||||||
val callable = scope.get(extensionCallableName(className, member))
|
|
||||||
val getter = scope.get(extensionPropertyGetterName(className, member))
|
|
||||||
if (callable == null && getter == null) {
|
|
||||||
missing += "$className.$member"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assertTrue(missing.isEmpty(), "Missing stdlib extension wrappers: ${missing.sorted()}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -22,23 +22,6 @@ extern class Iterator<T> {
|
|||||||
fun toList(): List<T>
|
fun toList(): List<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
extern class Collection<T> : Iterable<T> {
|
|
||||||
}
|
|
||||||
|
|
||||||
extern class Array<T> : Collection<T> {
|
|
||||||
}
|
|
||||||
|
|
||||||
extern class List<T> : Array<T> {
|
|
||||||
}
|
|
||||||
|
|
||||||
extern class Set<T> : Collection<T> {
|
|
||||||
}
|
|
||||||
|
|
||||||
extern class Map<K,V> {
|
|
||||||
}
|
|
||||||
|
|
||||||
extern class MapEntry<K,V>
|
|
||||||
|
|
||||||
// Built-in math helpers (implemented in host runtime).
|
// Built-in math helpers (implemented in host runtime).
|
||||||
extern fun abs(x: Object): Real
|
extern fun abs(x: Object): Real
|
||||||
extern fun ln(x: Object): Real
|
extern fun ln(x: Object): Real
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user