-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added scala 2 annotation equivalent, but 2.12 needs some love
- Loading branch information
Showing
5 changed files
with
149 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
parsley-debug/shared/src/test/scala-2/scala/annotation/experimental.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* Copyright 2020 Parsley Contributors <https://github.com/j-mie6/Parsley/graphs/contributors> | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
package scala.annotation | ||
|
||
// this fills in the gap for 2.13 and 2.12: we can't use 3.4's -experimental flag | ||
class experimental extends StaticAnnotation |
27 changes: 27 additions & 0 deletions
27
parsley-debug/shared/src/test/scala/annotation/AnnotationTestObjects.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright 2020 Parsley Contributors <https://github.com/j-mie6/Parsley/graphs/contributors> | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
package annotation | ||
import parsley.Parsley | ||
import parsley.quick._ | ||
|
||
import scala.annotation.experimental | ||
|
||
@experimental @parsley.debuggable | ||
object otherParsers { | ||
val a = char('b') | ||
} | ||
|
||
@experimental @parsley.debuggable | ||
class parsers(val x: Int) { | ||
val p = char('a') | ||
val q = p ~> p | ||
lazy val r: Parsley[Char] = ~r ~> q | ||
def s = otherParsers.a | ||
val y = 7 | ||
|
||
def this(f: Float) = this(f.toInt) | ||
def many[A](p: Parsley[A]): Parsley[List[A]] = Parsley.many(p) | ||
} |
24 changes: 24 additions & 0 deletions
24
parsley-debug/shared/src/test/scala/parsley/AnnotationTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright 2020 Parsley Contributors <https://github.com/j-mie6/Parsley/graphs/contributors> | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
package parsley | ||
|
||
import scala.annotation.experimental | ||
import parsley.debugger.internal.Renamer | ||
|
||
@experimental | ||
class AnnotationTest extends ParsleyTest { | ||
"parsley.debuggable" should "fill in the names for objects" in { | ||
Renamer.nameOf(None, annotation.otherParsers.a.internal) shouldBe "a" | ||
} | ||
|
||
it should "fill in the names for classes" in { | ||
val parsers = new annotation.parsers(6) | ||
Renamer.nameOf(None, parsers.p.internal) shouldBe "p" | ||
Renamer.nameOf(None, parsers.q.internal) shouldBe "q" | ||
Renamer.nameOf(None, parsers.r.internal) shouldBe "r" | ||
Renamer.nameOf(None, parsers.s.internal) should not be ("char") // see the objects lol | ||
} | ||
} |