Skip to content

Commit 6e2a474

Browse files
Duhemmshadaj
authored andcommitted
Cross compile to Scala Native
1 parent 720b9b3 commit 6e2a474

File tree

5 files changed

+60
-2
lines changed

5 files changed

+60
-2
lines changed

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
language: scala
2+
dist: trusty
23
script: ./tools/travis-script.sh
34
after_success: ./tools/travis-deploy.sh
45
branches:
@@ -30,3 +31,11 @@ env:
3031
- PLATFORM=js SBT_PARALLEL=true WORKERS=1 DEPLOY=true
3132
- PLATFORM=js SBT_PARALLEL=true WORKERS=1 DEPLOY=true SCALAJS_VERSION=1.0.0-M1
3233
sudo: false
34+
35+
matrix:
36+
include:
37+
- scala: 2.11.11
38+
before_script:
39+
- curl https://raw.githubusercontent.com/scala-native/scala-native/21539aa97947f767afcd85b5c2fb3c0262b2d301/bin/travis_setup.sh | bash -x
40+
sudo: required
41+
env: PLATFORM=native SBT_PARALLEL=true WORKERS=1 DEPLOY=true

build.sbt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,14 @@ lazy val jvm = project.in(file("jvm"))
129129
.settings(
130130
libraryDependencies += "org.scala-sbt" % "test-interface" % "1.0"
131131
)
132+
133+
lazy val native = project.in(file("native"))
134+
.settings(sharedSettings: _*)
135+
.settings(
136+
doc in Compile := (doc in Compile in jvm).value,
137+
scalaVersion := "2.11.11",
138+
libraryDependencies ++= Seq(
139+
"org.scala-native" %% "test-interface_native0.3" % "0.3.1"
140+
)
141+
)
142+
.enablePlugins(ScalaNativePlugin)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*-------------------------------------------------------------------------*\
2+
** ScalaCheck **
3+
** Copyright (c) 2007-2017 Rickard Nilsson. All rights reserved. **
4+
** http://www.scalacheck.org **
5+
** **
6+
** This software is released under the terms of the Revised BSD License. **
7+
** There is NO WARRANTY. See the file LICENSE for the full text. **
8+
\*------------------------------------------------------------------------ */
9+
10+
package org.scalacheck
11+
12+
import Test._
13+
14+
import scala.scalanative.testinterface.PreloadedClassLoader
15+
16+
private[scalacheck] object Platform {
17+
18+
def runWorkers(
19+
params: Parameters,
20+
workerFun: Int => Result,
21+
stop: () => Unit
22+
): Result = {
23+
workerFun(0)
24+
}
25+
26+
def loadModule(name: String, loader: ClassLoader): AnyRef =
27+
loader.asInstanceOf[PreloadedClassLoader].loadPreloaded(name)
28+
29+
def newInstance(name: String, loader: ClassLoader, paramTypes: Seq[Class[_]])(args: Seq[AnyRef]): AnyRef =
30+
org.scalajs.testinterface.TestUtils.newInstance(name, loader, paramTypes)(args)
31+
32+
// We don't need those annotation in Native, and they have been deprecated.
33+
// We use `String` instead of the definition in Native because `-Xfatal-warnings`
34+
// is set.
35+
type EnableReflectiveInstantiation = String
36+
}

project/plugin.sbt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ val scalaJSVersion =
77

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

10+
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.3.3")
11+
1012
scalacOptions += "-deprecation"

src/test/scala/org/scalacheck/PropSpecification.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ object PropSpecification extends Properties("Prop") {
144144
}
145145

146146
property("throws") = throws(classOf[java.lang.Exception]) {
147-
val s: String = null
148-
s.length
147+
val it: Iterator[Int] = Iterator.empty
148+
it.next()
149149
}
150150

151151
property("sizedProp") = {

0 commit comments

Comments
 (0)