Skip to content

Scala.js: Enable JS-specific tests that already pass. #9461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,31 @@ class JSCodeGen()(using genCtx: Context) {

/** Gen the IR ClassDef for a Scala.js-defined JS class. */
private def genScalaJSDefinedJSClass(td: TypeDef): js.ClassDef = {
???
val sym = td.symbol.asClass
implicit val pos: SourcePosition = sym.sourcePos

assert(!sym.is(Trait),
"genScalaJSDefinedJSClass() must be called only for normal classes: "+sym)
assert(sym.superClass != NoSymbol, sym)

val classIdent = encodeClassNameIdent(sym)
val originalName = originalNameOfClass(sym)

report.error("cannot emit non-native JS classes yet", td.sourcePos)

// Dummy result
js.ClassDef(
classIdent,
originalName,
ClassKind.JSClass,
None,
Some(encodeClassNameIdent(sym.superClass)),
genClassInterfaces(sym),
None,
None,
Nil,
Nil)(
OptimizerHints.empty)
}

/** Gen the IR ClassDef for a raw JS class or trait.
Expand Down
80 changes: 80 additions & 0 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,9 @@ object Build {
)
}.taskValue,

scalaJSLinkerConfig ~= { _.withSemantics(build.TestSuiteLinkerOptions.semantics _) },
scalaJSModuleInitializers in Test ++= build.TestSuiteLinkerOptions.moduleInitializers,

managedSources in Compile ++= {
val dir = fetchScalaJSSource.value / "test-suite/js/src/main/scala"
val filter = (
Expand Down Expand Up @@ -1063,6 +1066,83 @@ object Build {
++ (dir / "shared/src/test/require-jdk7/org/scalajs/testsuite/javalib/io" ** "*.scala").get
++ (dir / "shared/src/test/require-jdk7/org/scalajs/testsuite/javalib/lang" ** "*.scala").get
++ (dir / "shared/src/test/require-jdk7/org/scalajs/testsuite/javalib/util" ** "*.scala").get

++ (dir / "js/src/test/scala/org/scalajs/testsuite/compiler" ** (("*.scala": FileFilter)
-- "InteroperabilityTest.scala" // various compile errors
-- "OptimizerTest.scala" // compile errors: false + string and () + string
-- "ReflectionTest.scala" // tests fail
-- "RegressionJSTest.scala" // compile error with js.Dynamic.literal
-- "RuntimeTypesTest.scala" // compile errors: no ClassTag for Null and Nothing
)).get

++ (dir / "js/src/test/scala/org/scalajs/testsuite/javalib" ** (("*.scala": FileFilter)
-- "FormatterJSTest.scala" // compile error with the f"" interpolator
-- "ObjectJSTest.scala" // non-native JS classes
-- "StringBufferJSTest.scala" // IR checking errors
-- "ThrowableJSTest.scala" // test fails ("java.lang.Error: stub")
)).get

++ (dir / "js/src/test/scala/org/scalajs/testsuite/jsinterop" ** (("*.scala": FileFilter)
-- "AsyncTest.scala" // needs PromiseMock.scala
-- "DynamicTest.scala" // compile error with js.Dynamic.literal
-- "ExportsTest.scala" // JS exports
-- "FunctionTest.scala" // IR checking errors
-- "IterableTest.scala" // non-native JS classes
-- "JSExportStaticTest.scala" // JS exports
-- "JSNameTest.scala" // compile error with js.Dynamic.literal
-- "JSNativeInPackage.scala" // IR checking errors
-- "JSOptionalTest.scala" // non-native JS classes
-- "JSSymbolTest.scala" // compile error with js.Dynamic.literal
-- "MiscInteropTest.scala" // compile error with js.Dynamic.literal
-- "ModulesWithGlobalFallbackTest.scala" // non-native JS classes
-- "NestedJSClassTest.scala" // non-native JS classes
-- "NonNativeJSTypeTest.scala" // non-native JS classes
-- "PromiseMock.scala" // non-native JS classes
-- "SpecialTest.scala" // compile error with js.Dynamic.literal
-- "SymbolTest.scala" // IR checking errors
-- "ThisFunctionTest.scala" // compile error with js.Dynamic.literal
-- "UndefOrTest.scala" // StackOverflow in the compiler
)).get

++ (dir / "js/src/test/scala/org/scalajs/testsuite/junit" ** (("*.scala": FileFilter)
// Tests fail
-- "JUnitAbstractClassTest.scala"
-- "JUnitNamesTest.scala"
-- "JUnitSubClassTest.scala"
-- "MultiCompilationSecondUnitTest.scala"
)).get

++ (dir / "js/src/test/scala/org/scalajs/testsuite/library" ** (("*.scala": FileFilter)
-- "BigIntTest.scala" // StackOverflow in the compiler
-- "ObjectTest.scala" // compile errors
-- "StackTraceTest.scala" // would require `npm install source-map-support`
-- "UnionTypeTest.scala" // requires a Scala 2 macro + StackOverflow in the compiler
-- "WrappedDictionaryTest.scala" // IR checking errors
)).get

++ (dir / "js/src/test/scala/org/scalajs/testsuite/niobuffer" ** "*.scala").get

++ (dir / "js/src/test/scala/org/scalajs/testsuite/scalalib" ** (("*.scala": FileFilter)
-- "ScalaRunTimeJSTest.scala" // compile error with js.Dynamic.literal
)).get

++ (dir / "js/src/test/scala/org/scalajs/testsuite/typedarray" ** (("*.scala": FileFilter)
-- "TypedArrayTest.scala" // assertion error in ExpandSAMs
)).get

++ (dir / "js/src/test/scala/org/scalajs/testsuite/utils" ** "*.scala").get

++ (dir / "js/src/test/require-2.12" ** (("*.scala": FileFilter)
-- "JSOptionalTest212.scala" // non-native JS classes
)).get

++ (dir / "js/src/test/require-sam" ** (("*.scala": FileFilter)
-- "SAMJSTest.scala" // non-native JS classes
)).get

++ (dir / "js/src/test/scala-new-collections" ** (("*.scala": FileFilter)
-- "WrappedDictionaryToTest.scala" // IR checking errors
)).get
)
}
)
Expand Down
39 changes: 39 additions & 0 deletions project/TestSuiteLinkerOptions.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package build

// This file is an exact copy of the file of the same name in scala-js/scala-js

import org.scalajs.linker.interface._

object TestSuiteLinkerOptions {

def semantics(s: Semantics): Semantics = {
import Semantics.RuntimeClassNameMapper

s.withRuntimeClassNameMapper(
RuntimeClassNameMapper.keepAll().andThen(
RuntimeClassNameMapper.regexReplace(
raw"""^org\.scalajs\.testsuite\.compiler\.ReflectionTest\$$RenamedTestClass$$""".r,
"renamed.test.Class")
).andThen(
RuntimeClassNameMapper.regexReplace(
raw"""^org\.scalajs\.testsuite\.compiler\.ReflectionTest\$$Prefix""".r,
"renamed.test.byprefix.")
).andThen(
RuntimeClassNameMapper.regexReplace(
raw"""^org\.scalajs\.testsuite\.compiler\.ReflectionTest\$$OtherPrefix""".r,
"renamed.test.byotherprefix.")
)
)
}

def moduleInitializers: List[ModuleInitializer] = {
val module = "org.scalajs.testsuite.compiler.ModuleInitializers"
List(
ModuleInitializer.mainMethod(module, "mainNoArgs"),
ModuleInitializer.mainMethodWithArgs(module, "mainWithArgs"),
ModuleInitializer.mainMethodWithArgs(module, "mainWithArgs", List("foo", "bar")),
ModuleInitializer.mainMethod(module + "$NoLinkedClass", "main"),
ModuleInitializer.mainMethod(module + "$WithLinkedClass", "main")
)
}
}