Skip to content

Commit c3f34ae

Browse files
committed
scala 2.12 still has macro issue. scala-native still has test issue.
1 parent 467ae30 commit c3f34ae

File tree

12 files changed

+49
-53
lines changed

12 files changed

+49
-53
lines changed

js/src/test/scala/json/ExportTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import scala.scalajs.js.annotation.JSExport
2020
import scalajs.js
2121

2222
import utest._
23-
import utest.ExecutionContext.RunNow
23+
import utest.framework.ExecutionContext.RunNow
2424

2525
class ExportTest extends js.JSApp {
2626
@JSExport

js/src/test/scala/json/JSTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ object JSTest extends TestSuite {
3131
assert(JSJValue.from(x) == result)
3232
}
3333

34-
val tests = TestSuite("test JS" - {
34+
val tests = this("test JS" - {
3535
"test native JSON" - {
3636
val str = Tester.testJSON2
3737
val native = NativeJSON.parse(str)

jvm/src/test/scala/json/JVMJSONTest.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ package json
1818

1919
import json.internal.PrimitiveJArray
2020
import utest._
21-
import utest.framework.TestSuite
2221

2322
class JVMJSONTest extends TestSuite {
2423

25-
val tests = TestSuite {
24+
val tests = this {
2625
"use primitive arrays" - {
2726
val arrJS = JArray(JTrue, JFalse, JTrue).toString
2827
val parsed = JValue.fromString(arrJS).jArray

native/src/main/scala/json/internal/JanssonDeserializer.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package json.internal
1919
import scalanative.native
2020

2121
import janssonConstants._
22+
import janssonTypes._
2223
import jansson._
2324
import native._
2425
import json._

native/src/main/scala/json/internal/jansson.scala

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,7 @@ import Nat._
2323
@native.link("jansson")
2424
@native.extern
2525
object jansson {
26-
type JSON_ERROR_TEXT_LENGTH = Digit[_1, Digit[_6, _0]]
27-
type JSON_ERROR_SOURCE_LENGTH = Digit[_8, _0]
28-
29-
type json_type = CInt //enum
30-
31-
type json_error_t = CStruct5[
32-
CInt, //line
33-
CInt, //column
34-
CInt, //position,
35-
CArray[CChar, JSON_ERROR_SOURCE_LENGTH], //source
36-
CArray[CChar, JSON_ERROR_TEXT_LENGTH] //text
37-
]
38-
39-
type json_t = CStruct2[
40-
json_type, //type
41-
CSize //refcount
42-
]
43-
44-
type json_iter = Ptr[Byte]
26+
import janssonTypes._
4527

4628
def json_loads(input: CString, flags: CSize, error: Ptr[json_error_t]): Ptr[json_t] = extern
4729

@@ -70,6 +52,28 @@ object jansson {
7052
def json_string_value(str: Ptr[json_t]): CString = extern
7153
}
7254

55+
object janssonTypes {
56+
type JSON_ERROR_TEXT_LENGTH = Digit[_1, Digit[_6, _0]]
57+
type JSON_ERROR_SOURCE_LENGTH = Digit[_8, _0]
58+
59+
type json_type = CInt //enum
60+
61+
type json_error_t = CStruct5[
62+
CInt, //line
63+
CInt, //column
64+
CInt, //position,
65+
CArray[CChar, JSON_ERROR_SOURCE_LENGTH], //source
66+
CArray[CChar, JSON_ERROR_TEXT_LENGTH] //text
67+
]
68+
69+
type json_t = CStruct2[
70+
json_type, //type
71+
CSize //refcount
72+
]
73+
74+
type json_iter = Ptr[Byte]
75+
}
76+
7377
object janssonConstants {
7478
//json_type
7579
val JSON_OBJECT = 0

project/ScalaJSON.scala

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ object ScalaJSON {
5353
organizationName := "MediaMath, Inc",
5454
organizationHomepage := Some(url("http://www.mediamath.com")),
5555
crossPaths := true,
56-
crossScalaVersions := Seq("2.10.6", targetScalaVer, "2.12.0-M3"),
56+
crossScalaVersions := Seq("2.10.6", targetScalaVer, "2.12.1"),
5757
resolvers += Resolver.sonatypeRepo("releases"),
5858
addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full)
5959
)
@@ -107,10 +107,7 @@ object ScalaJSON {
107107
</developers>
108108
},
109109

110-
//temporary resolver for colinrgodsey fork of [email protected] for 2.12.0-M3 support
111-
resolvers += "mvn repo" at "https://raw.githubusercontent.com/colinrgodsey/maven/master",
112-
113-
libraryDependencies += "com.lihaoyi" %%% "utest" % "0.3.1" % "test",
110+
libraryDependencies += "com.lihaoyi" %%% "utest" % "0.4.5" % "test",
114111

115112
testFrameworks += new TestFramework("utest.runner.Framework")
116113
)

project/plugins.sbt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ resolvers += Resolver.url(
66
addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.3.2")
77

88
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.14")
9-
addSbtPlugin("org.scala-native" % "sbt-crossproject" % "0.1.0") // (1)
10-
addSbtPlugin("org.scala-native" % "sbt-scalajs-crossproject" % "0.1.0") // (2)
11-
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.1.0") // (3)
9+
addSbtPlugin("org.scala-native" % "sbt-crossproject" % "0.1.0")
10+
addSbtPlugin("org.scala-native" % "sbt-scalajs-crossproject" % "0.1.0")
11+
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.1.0")

shared/src/main/scala/json/internal/ObjectAccessorFactory.scala

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,7 @@ object ObjectAccessorFactory {
184184
val nameConversion = nameConversionAnno.headOption match {
185185
case None => reify {s: String => s}.tree
186186
case Some(anno) =>
187-
println(showRaw(anno))
188187
val outTree = anno.tree.children.tail.head
189-
println(showRaw(outTree))
190-
println(show(outTree))
191188
outTree
192189
}
193190
val nameConversionExpr = c.Expr[String => String](nameConversion)
@@ -214,16 +211,15 @@ object ObjectAccessorFactory {
214211

215212
val objMfExpr = classExpr(typ0)
216213

217-
val memberAnnos = (for {
218-
mem <- typ0.members
219-
anno <- mem.annotations
220-
if anno.tree.tpe <:< typeOf[JSONAnnotation]
221-
} yield mem.name -> anno) ++ (for {
222-
paramSet <- applyMethod.paramLists
223-
param <- paramSet
224-
anno <- param.annotations
214+
val memberSymbols: Iterable[Symbol] =
215+
typ0.members ++ applyMethod.paramLists.flatten ++
216+
typ0.decls ++ typ0.companion.paramLists.flatten
217+
218+
val memberAnnos = for {
219+
sym <- memberSymbols
220+
anno <- sym.annotations
225221
if anno.tree.tpe <:< typeOf[JSONAnnotation]
226-
} yield param.name -> anno)
222+
} yield sym.name -> anno
227223

228224
//scan for annotations that show we should use a
229225
//different field name

shared/src/test/scala/json/JSONTest.scala

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package json
1919

2020
import json.internal.PrimitiveJArray
2121
import json.tools.{TypedEnumerator, Enumerator}
22-
import utest.framework.TestSuite
2322
import utest._
2423

2524
import scala.annotation.meta
@@ -37,23 +36,23 @@ object Tester extends TestSuite {
3736
implicit val acc = ObjectAccessor.create[TestObject3]
3837
}
3938

40-
object TestObject2 {
41-
implicit val acc = ObjectAccessor.create[TestObject2]
42-
}
4339
case class TestObject2(a: String, b: String, qqq: Double = 2.456,
4440
c: String = "ddddd", d: Option[String] = Some("XXXX"),
4541
@name(field = "aa11") @Tester.NumAnno(11) ffff: Option[String] = None,
4642
@name(field = "zzz2") zzz: Map[String, TestObject3] = Map("asfa" ->
4743
TestObject3("", 0.5, 4)),
4844
seqa: Seq[Int] = Nil,
4945
blah: Int = 123)
50-
51-
object TestObject {
52-
implicit val acc = ObjectAccessor.create[TestObject]
46+
object TestObject2 {
47+
implicit val acc = ObjectAccessor.create[TestObject2]
5348
}
49+
5450
case class TestObject(a: String,
5551
@name(field = "BLAH") b: String,
5652
c: Int, d: TestObject2)
53+
object TestObject {
54+
implicit val acc = ObjectAccessor.create[TestObject]
55+
}
5756

5857
trait TestTrait {
5958
def num: Int
@@ -106,7 +105,7 @@ object Tester extends TestSuite {
106105
def testJSONEqual(jv: JValue) =
107106
assert(JValue.fromString(jv.toString) == jv)
108107

109-
val tests = TestSuite {
108+
val tests = this {
110109
"JSON accessor should" - {
111110
val test3 = TestObject3("", 0.5, 4)
112111
val test2 = TestObject2("sdfsdg", "dfdfd")

0 commit comments

Comments
 (0)