Skip to content
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

Updated version of #337: Cross compile to Scala Native #368

Merged
merged 1 commit into from
Dec 20, 2017
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
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