Skip to content

Commit 794844c

Browse files
authored
Merge pull request #371 from danicheg/native
Add support for Scala Native
2 parents b11dc55 + 41e0038 commit 794844c

File tree

7 files changed

+126
-17
lines changed

7 files changed

+126
-17
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
name: Build and Test
2828
strategy:
2929
matrix:
30-
os: [ubuntu-latest]
30+
os: [ubuntu-22.04]
3131
scala: [2.12.17, 3.2.0, 2.13.9]
3232
java: [temurin@8, temurin@17]
3333
exclude:
@@ -106,11 +106,11 @@ jobs:
106106

107107
- name: Make target directories
108108
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
109-
run: mkdir -p target js/target jvm/target site/target project/target
109+
run: mkdir -p js/target target site/target jvm/target native/target project/target
110110

111111
- name: Compress target directories
112112
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
113-
run: tar cf targets.tar target js/target jvm/target site/target project/target
113+
run: tar cf targets.tar js/target target site/target jvm/target native/target project/target
114114

115115
- name: Upload target directories
116116
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
@@ -125,7 +125,7 @@ jobs:
125125
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
126126
strategy:
127127
matrix:
128-
os: [ubuntu-latest]
128+
os: [ubuntu-22.04]
129129
scala: [2.13.9]
130130
java: [temurin@8]
131131
runs-on: ${{ matrix.os }}

.jvmopts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-Xms1G
2+
-Xmx4G
3+
-XX:+UseG1GC

build.sbt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,31 @@ val Scala3 = "3.2.0"
44

55
ThisBuild / organization := "org.typelevel"
66
ThisBuild / organizationName := "Typelevel"
7-
ThisBuild / tlBaseVersion := "1.1"
7+
ThisBuild / tlBaseVersion := "1.2"
88
ThisBuild / scalaVersion := Scala213
99
ThisBuild / crossScalaVersions := Seq(Scala212, Scala3, Scala213)
1010
ThisBuild / tlVersionIntroduced := Map("3" -> "1.0.3")
1111
ThisBuild / tlCiReleaseBranches := Seq("main")
1212
ThisBuild / tlSiteApiUrl := Some(url("https://www.javadoc.io/doc/org.typelevel/mouse_2.13/latest"))
13+
ThisBuild / githubWorkflowOSes := Seq("ubuntu-22.04")
1314

1415
lazy val root = project
1516
.in(file("."))
1617
.settings(
1718
name := "mouse",
1819
licenses := List(License.MIT)
1920
)
20-
.aggregate(js, jvm)
21+
.aggregate(js, jvm, native)
2122
.enablePlugins(NoPublishPlugin)
2223

23-
lazy val cross = crossProject(JSPlatform, JVMPlatform)
24+
lazy val cross = crossProject(JSPlatform, JVMPlatform, NativePlatform)
2425
.in(file("."))
2526
.settings(
2627
name := "mouse",
2728
libraryDependencies ++= Seq(
2829
"org.typelevel" %%% "cats-core" % "2.8.0",
29-
"org.scalameta" %%% "munit" % "0.7.29" % Test,
30-
"org.scalameta" %%% "munit-scalacheck" % "0.7.29" % Test
30+
"org.scalameta" %%% "munit" % "1.0.0-M6" % Test,
31+
"org.scalameta" %%% "munit-scalacheck" % "1.0.0-M6" % Test
3132
),
3233
ThisBuild / licenses := List("MIT license" -> url("http://opensource.org/licenses/MIT")),
3334
developers := List(
@@ -50,6 +51,9 @@ lazy val cross = crossProject(JSPlatform, JVMPlatform)
5051
.jsSettings(
5152
tlVersionIntroduced := Map("3" -> "1.0.13")
5253
)
54+
.nativeSettings(
55+
tlVersionIntroduced := List("2.12", "2.13", "3").map(_ -> "1.2.0").toMap
56+
)
5357

5458
lazy val docs = project
5559
.in(file("site"))
@@ -63,6 +67,7 @@ ThisBuild / githubWorkflowJavaVersions := Seq(JDK8, JDK17)
6367

6468
lazy val jvm = cross.jvm
6569
lazy val js = cross.js
70+
lazy val native = cross.native
6671

6772
// Scalafmt
6873
addCommandAlias("fmt", "; Compile / scalafmt; Test / scalafmt; scalafmtSbt")
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright (c) 2016 Typelevel
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
5+
* this software and associated documentation files (the "Software"), to deal in
6+
* the Software without restriction, including without limitation the rights to
7+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8+
* the Software, and to permit persons to whom the Software is furnished to do so,
9+
* subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in all
12+
* copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
*/
21+
22+
package object mouse extends MouseFunctions {
23+
object all extends AllSharedSyntax
24+
object any extends AnySyntax
25+
object anyf extends AnyFSyntax
26+
object boolean extends BooleanSyntax
27+
object double extends DoubleSyntax
28+
object fboolean extends FBooleanSyntax
29+
object feither extends FEitherSyntax
30+
object fnested extends FNestedSyntax
31+
object foption extends FOptionSyntax
32+
object ftuple extends FTupleSyntax
33+
object int extends IntSyntax
34+
object list extends ListSyntax
35+
object long extends LongSyntax
36+
object map extends MapSyntax
37+
object option extends OptionSyntax
38+
object set extends SetSyntax
39+
object string extends StringSyntax
40+
object `try` extends TrySyntax
41+
object tuple extends TupleSyntax
42+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (c) 2016 Typelevel
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
5+
* this software and associated documentation files (the "Software"), to deal in
6+
* the Software without restriction, including without limitation the rights to
7+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8+
* the Software, and to permit persons to whom the Software is furnished to do so,
9+
* subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in all
12+
* copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
*/
21+
22+
package object mouse extends MouseFunctions {
23+
object all extends AllSharedSyntax
24+
object any extends AnySyntax
25+
object anyf extends AnyFSyntax
26+
object boolean extends BooleanSyntax
27+
object double extends DoubleSyntax
28+
object fboolean extends FBooleanSyntax
29+
object feither extends FEitherSyntax
30+
object fnested extends FNestedSyntax
31+
object foption extends FOptionSyntax
32+
object ftuple extends FTupleSyntax
33+
object int extends IntSyntax
34+
object list extends ListSyntax
35+
object long extends LongSyntax
36+
object map extends MapSyntax
37+
object option extends OptionSyntax
38+
object set extends SetSyntax
39+
object string extends StringSyntax
40+
object `try` extends TrySyntax
41+
}

project/plugins.sbt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.1")
22
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0")
3+
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.7")
4+
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0")
35
addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.4.15")
46
addSbtPlugin("org.typelevel" % "sbt-typelevel-site" % "0.4.15")

shared/src/test/scala/mouse/StringSyntaxTests.scala

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ import org.scalacheck.{Arbitrary, Gen}
2929
class StringSyntaxTests extends MouseSuite {
3030
test("StringOps.parseInt") {
3131
assertEquals("123".parseInt, 123.asRight[NumberFormatException])
32-
assertEquals("blah".parseInt.leftMap(_.getMessage), "For input string: \"blah\"".asLeft)
32+
assertEquals("blah".parseInt.leftMap(_.getMessage.replace("string ", "string: ")),
33+
"For input string: \"blah\"".asLeft
34+
)
3335
}
3436

3537
property("scalacheck-suite: StringOps.parseInt") {
@@ -48,7 +50,9 @@ class StringSyntaxTests extends MouseSuite {
4850

4951
test("StringOps.parseLong") {
5052
assertEquals("123".parseLong, 123L.asRight[NumberFormatException])
51-
assertEquals("blah".parseLong.leftMap(_.getMessage), "For input string: \"blah\"".asLeft)
53+
assertEquals("blah".parseLong.leftMap(_.getMessage.replace("string ", "string: ")),
54+
"For input string: \"blah\"".asLeft
55+
)
5256
}
5357

5458
property("scalacheck-suite: StringOps.parseLong") {
@@ -67,7 +71,9 @@ class StringSyntaxTests extends MouseSuite {
6771

6872
test("StringOps.parseShort") {
6973
assertEquals("123".parseShort, 123.toShort.asRight[NumberFormatException])
70-
assertEquals("blah".parseShort.leftMap(_.getMessage), "For input string: \"blah\"".asLeft)
74+
assertEquals("blah".parseShort.leftMap(_.getMessage.replace("string ", "string: ")),
75+
"For input string: \"blah\"".asLeft
76+
)
7177
}
7278

7379
property("scalacheck-suite: StringOps.parseShort") {
@@ -86,7 +92,9 @@ class StringSyntaxTests extends MouseSuite {
8692

8793
test("StringOps.parseDouble") {
8894
assertEquals("123.1".parseDouble, 123.1.asRight[NumberFormatException])
89-
assertEquals("blah".parseDouble.leftMap(_.getMessage), "For input string: \"blah\"".asLeft)
95+
assertEquals("blah".parseDouble.leftMap(_.getMessage.replace("string ", "string: ")),
96+
"For input string: \"blah\"".asLeft
97+
)
9098
}
9199

92100
property("scalacheck-suite: StringOps.parseDouble") {
@@ -104,7 +112,9 @@ class StringSyntaxTests extends MouseSuite {
104112
}
105113

106114
test("StringOps.parseFloat") {
107-
assertEquals("blah".parseFloat.leftMap(_.getMessage), "For input string: \"blah\"".asLeft)
115+
assertEquals("blah".parseFloat.leftMap(_.getMessage.replace("string ", "string: ")),
116+
"For input string: \"blah\"".asLeft
117+
)
108118
}
109119

110120
property("scalacheck-suite: StringOps.parseFloat") {
@@ -123,7 +133,9 @@ class StringSyntaxTests extends MouseSuite {
123133

124134
test("StringOps.parseByte") {
125135
assertEquals("123".parseByte, 123.toByte.asRight[NumberFormatException])
126-
assertEquals("blah".parseByte.leftMap(_.getMessage), "For input string: \"blah\"".asLeft)
136+
assertEquals("blah".parseByte.leftMap(_.getMessage.replace("string ", "string: ")),
137+
"For input string: \"blah\"".asLeft
138+
)
127139
}
128140

129141
property("scalacheck-suite: StringOps.parseByte") {
@@ -142,7 +154,9 @@ class StringSyntaxTests extends MouseSuite {
142154

143155
test("StringOps.parseBigInt") {
144156
assertEquals("123".parseBigInt, BigInt("123").asRight[NumberFormatException])
145-
assertEquals("blah".parseBigInt.leftMap(_.getMessage), "For input string: \"blah\"".asLeft)
157+
assertEquals("blah".parseBigInt.leftMap(_.getMessage.replace("string ", "string: ")),
158+
"For input string: \"blah\"".asLeft
159+
)
146160
}
147161

148162
property("scalacheck-suite: StringOps.parseBigInt") {
@@ -196,7 +210,9 @@ class StringSyntaxTests extends MouseSuite {
196210
Arbitrary.arbString.arbitrary.filter(s => !s.equalsIgnoreCase("true") && !s.equalsIgnoreCase("false"))
197211

198212
forAll(stringGen) { (s: String) =>
199-
assertEquals(s.parseBoolean.leftMap(_.getMessage), ("For input string: \"" + s + "\"").asLeft)
213+
assertEquals(s.parseBoolean.leftMap(_.getMessage.replace("string ", "string: ")),
214+
("For input string: \"" + s + "\"").asLeft
215+
)
200216
}
201217
}
202218

0 commit comments

Comments
 (0)