Skip to content

Commit

Permalink
Cross compile to Scala Native
Browse files Browse the repository at this point in the history
  • Loading branch information
Duhemm authored and shadaj committed Dec 4, 2017
1 parent 720b9b3 commit 6e2a474
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 2 deletions.
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
language: scala
dist: trusty
script: ./tools/travis-script.sh
after_success: ./tools/travis-deploy.sh
branches:
Expand Down Expand Up @@ -30,3 +31,11 @@ env:
- PLATFORM=js SBT_PARALLEL=true WORKERS=1 DEPLOY=true
- PLATFORM=js SBT_PARALLEL=true WORKERS=1 DEPLOY=true SCALAJS_VERSION=1.0.0-M1
sudo: false

matrix:
include:
- scala: 2.11.11
before_script:
- curl https://raw.githubusercontent.com/scala-native/scala-native/21539aa97947f767afcd85b5c2fb3c0262b2d301/bin/travis_setup.sh | bash -x
sudo: required
env: PLATFORM=native SBT_PARALLEL=true WORKERS=1 DEPLOY=true
11 changes: 11 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,14 @@ lazy val jvm = project.in(file("jvm"))
.settings(
libraryDependencies += "org.scala-sbt" % "test-interface" % "1.0"
)

lazy val native = project.in(file("native"))
.settings(sharedSettings: _*)
.settings(
doc in Compile := (doc in Compile in jvm).value,
scalaVersion := "2.11.11",
libraryDependencies ++= Seq(
"org.scala-native" %% "test-interface_native0.3" % "0.3.1"
)
)
.enablePlugins(ScalaNativePlugin)
36 changes: 36 additions & 0 deletions native/src/main/scala/org/scalacheck/Platform.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*-------------------------------------------------------------------------*\
** ScalaCheck **
** Copyright (c) 2007-2017 Rickard Nilsson. All rights reserved. **
** http://www.scalacheck.org **
** **
** This software is released under the terms of the Revised BSD License. **
** There is NO WARRANTY. See the file LICENSE for the full text. **
\*------------------------------------------------------------------------ */

package org.scalacheck

import Test._

import scala.scalanative.testinterface.PreloadedClassLoader

private[scalacheck] object Platform {

def runWorkers(
params: Parameters,
workerFun: Int => Result,
stop: () => Unit
): Result = {
workerFun(0)
}

def loadModule(name: String, loader: ClassLoader): AnyRef =
loader.asInstanceOf[PreloadedClassLoader].loadPreloaded(name)

def newInstance(name: String, loader: ClassLoader, paramTypes: Seq[Class[_]])(args: Seq[AnyRef]): AnyRef =
org.scalajs.testinterface.TestUtils.newInstance(name, loader, paramTypes)(args)

// We don't need those annotation in Native, and they have been deprecated.
// We use `String` instead of the definition in Native because `-Xfatal-warnings`
// is set.
type EnableReflectiveInstantiation = String
}
2 changes: 2 additions & 0 deletions project/plugin.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ val scalaJSVersion =

addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion)

addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.3.3")

scalacOptions += "-deprecation"
4 changes: 2 additions & 2 deletions src/test/scala/org/scalacheck/PropSpecification.scala
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ object PropSpecification extends Properties("Prop") {
}

property("throws") = throws(classOf[java.lang.Exception]) {
val s: String = null
s.length
val it: Iterator[Int] = Iterator.empty
it.next()
}

property("sizedProp") = {
Expand Down

0 comments on commit 6e2a474

Please sign in to comment.