Skip to content

Commit

Permalink
siste flytting
Browse files Browse the repository at this point in the history
  • Loading branch information
eirikm committed Aug 16, 2024
1 parent fb190e1 commit cb4613a
Show file tree
Hide file tree
Showing 755 changed files with 105 additions and 4,018 deletions.
35 changes: 5 additions & 30 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,36 +1,11 @@
//ThisBuild / name := "parse-combinator-ws"
ThisBuild / version := "1.0"
ThisBuild / scalaVersion := "3.4.2"

lazy val toml = (project in file("toml/toml-parser"))
.settings(
name := "toml",
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-parse" % "1.0.0",
"io.circe" %% "circe-core" % "0.14.9",
"io.circe" %% "circe-parser" % "0.14.9",
"org.scalatest" %% "scalatest" % "3.2.18" % Test
)
)
.enablePlugins(TomlTestPlugin)

lazy val simpleParsers = (project in file("simple-parsers")).settings(
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-parse" % "1.0.0",
"org.scalatest" %% "scalatest" % "3.2.18" % Test
)
)

lazy val jsonPointer = (project in file("jsonpointer")).settings(
name := "json-pointer",
lazy val oppgaver = (project in file("oppgaver")).settings(
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-parse" % "1.0.0",
"io.circe" %% "circe-core" % "0.14.9",
"io.circe" %% "circe-parser" % "0.14.9",
"org.scalatest" %% "scalatest" % "3.2.18" % Test
"org.typelevel" %% "cats-parse" % "1.0.0",
"io.circe" %% "circe-core" % "0.14.9",
"io.circe" %% "circe-parser" % "0.14.9",
"org.scalatest" %% "scalatest" % "3.2.18" % Test
)
)


lazy val root = (project in file("."))
.aggregate(simpleParsers, toml, jsonPointer)
Original file line number Diff line number Diff line change
@@ -1,110 +1,110 @@
package arktekk.jz2024.generated.toml
package arktekk.oppgave3

import io.circe.syntax.EncoderOps
import io.circe.parser.parse as parseJson
import io.circe.syntax.EncoderOps
import org.scalatest.funsuite.AnyFunSuite

class BoolInvalid extends AnyFunSuite {
test("mixed-case-true") {
val result = arktekk.jz2024.toml.toml.parseAll("""mixed-case-true = trUe
val result = arktekk.oppgave3.toml.parseAll("""mixed-case-true = trUe
|""".stripMargin)

assert(result.isLeft)
}

test("wrong-case-true") {
val result = arktekk.jz2024.toml.toml.parseAll("""wrong-case-true = TRUE
val result = arktekk.oppgave3.toml.parseAll("""wrong-case-true = TRUE
|""".stripMargin)

assert(result.isLeft)
}

test("starting-same-false") {
val result = arktekk.jz2024.toml.toml.parseAll("""starting-same-false = falsey
val result = arktekk.oppgave3.toml.parseAll("""starting-same-false = falsey
|""".stripMargin)

assert(result.isLeft)
}

test("almost-true") {
val result = arktekk.jz2024.toml.toml.parseAll("""almost-true = tru
val result = arktekk.oppgave3.toml.parseAll("""almost-true = tru
|""".stripMargin)

assert(result.isLeft)
}

test("mixed-case-false") {
val result = arktekk.jz2024.toml.toml.parseAll("""mixed-case-false = falsE
val result = arktekk.oppgave3.toml.parseAll("""mixed-case-false = falsE
|""".stripMargin)

assert(result.isLeft)
}

test("almost-false") {
val result = arktekk.jz2024.toml.toml.parseAll("""almost-false = fals
val result = arktekk.oppgave3.toml.parseAll("""almost-false = fals
|""".stripMargin)

assert(result.isLeft)
}

test("starting-same-true") {
val result = arktekk.jz2024.toml.toml.parseAll("""starting-same-true = truer
val result = arktekk.oppgave3.toml.parseAll("""starting-same-true = truer
|""".stripMargin)

assert(result.isLeft)
}

test("almost-false-with-extra") {
val result = arktekk.jz2024.toml.toml.parseAll("""almost-false-with-extra = falsify
val result = arktekk.oppgave3.toml.parseAll("""almost-false-with-extra = falsify
|""".stripMargin)

assert(result.isLeft)
}

test("capitalized-true") {
val result = arktekk.jz2024.toml.toml.parseAll("""capitalized-true = True
val result = arktekk.oppgave3.toml.parseAll("""capitalized-true = True
|""".stripMargin)

assert(result.isLeft)
}

test("capitalized-false") {
val result = arktekk.jz2024.toml.toml.parseAll("""capitalized-false = False
val result = arktekk.oppgave3.toml.parseAll("""capitalized-false = False
|""".stripMargin)

assert(result.isLeft)
}

test("wrong-case-false") {
val result = arktekk.jz2024.toml.toml.parseAll("""wrong-case-false = FALSE
val result = arktekk.oppgave3.toml.parseAll("""wrong-case-false = FALSE
|""".stripMargin)

assert(result.isLeft)
}

test("just-t") {
val result = arktekk.jz2024.toml.toml.parseAll("""just-t = t
val result = arktekk.oppgave3.toml.parseAll("""just-t = t
|""".stripMargin)

assert(result.isLeft)
}

test("just-f") {
val result = arktekk.jz2024.toml.toml.parseAll("""just-f = f
val result = arktekk.oppgave3.toml.parseAll("""just-f = f
|""".stripMargin)

assert(result.isLeft)
}

test("mixed-case") {
val result = arktekk.jz2024.toml.toml.parseAll("""mixed-case = valid = False
val result = arktekk.oppgave3.toml.parseAll("""mixed-case = valid = False
|""".stripMargin)

assert(result.isLeft)
}

test("almost-true-with-extra") {
val result = arktekk.jz2024.toml.toml.parseAll("""almost-true-with-extra = truthy
val result = arktekk.oppgave3.toml.parseAll("""almost-true-with-extra = truthy
|""".stripMargin)

assert(result.isLeft)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package arktekk.jz2024.generated.toml
package arktekk.oppgave3

import io.circe.syntax.EncoderOps
import io.circe.parser.parse as parseJson
import io.circe.syntax.EncoderOps
import org.scalatest.funsuite.AnyFunSuite

class BoolValid extends AnyFunSuite {
test("bool") {
val Right(result) = arktekk.jz2024.toml.toml.parseAll("""t = true
val Right(result) = arktekk.oppgave3.toml.parseAll("""t = true
|f = false
|""".stripMargin): @unchecked
val Right(expectedJson) = parseJson("""{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package arktekk.jz2024.generated.toml
package arktekk.oppgave3

import io.circe.syntax.EncoderOps
import io.circe.parser.parse as parseJson
import io.circe.syntax.EncoderOps
import org.scalatest.funsuite.AnyFunSuite

class DatetimeInvalid extends AnyFunSuite {
test("offset-overflow-minute") {
val result = arktekk.jz2024.toml.toml
val result = arktekk.oppgave3.toml
.parseAll("""# Minute must be 00-59; we allow 60 too because some people do write offsets of
|# 60 minutes
|d = 1985-06-18 17:04:07+12:61
Expand All @@ -16,70 +16,70 @@ class DatetimeInvalid extends AnyFunSuite {
}

test("month-under") {
val result = arktekk.jz2024.toml.toml.parseAll("""# date-month = 2DIGIT ; 01-12
val result = arktekk.oppgave3.toml.parseAll("""# date-month = 2DIGIT ; 01-12
|d = 2007-00-01T00:00:00-00:00
|""".stripMargin)

assert(result.isLeft)
}

test("feb-30") {
val result = arktekk.jz2024.toml.toml.parseAll(""""only 28 or 29 days in february" = 1988-02-30T15:15:15Z
val result = arktekk.oppgave3.toml.parseAll(""""only 28 or 29 days in february" = 1988-02-30T15:15:15Z
|""".stripMargin)

assert(result.isLeft)
}

test("no-leads-with-milli") {
val result = arktekk.jz2024.toml.toml.parseAll("""# Day "5" instead of "05"; the leading zero is required.
val result = arktekk.oppgave3.toml.parseAll("""# Day "5" instead of "05"; the leading zero is required.
|with-milli = 1987-07-5T17:45:00.12Z
|""".stripMargin)

assert(result.isLeft)
}

test("y10k") {
val result = arktekk.jz2024.toml.toml.parseAll("""# Maximum RFC3399 year is 9999.
val result = arktekk.oppgave3.toml.parseAll("""# Maximum RFC3399 year is 9999.
|d = 10000-01-01 00:00:00z
|""".stripMargin)

assert(result.isLeft)
}

test("no-t") {
val result = arktekk.jz2024.toml.toml.parseAll("""# No "t" or "T" between the date and time.
val result = arktekk.oppgave3.toml.parseAll("""# No "t" or "T" between the date and time.
|no-t = 1987-07-0517:45:00Z
|""".stripMargin)

assert(result.isLeft)
}

test("minute-over") {
val result = arktekk.jz2024.toml.toml.parseAll("""# time-minute = 2DIGIT ; 00-59
val result = arktekk.oppgave3.toml.parseAll("""# time-minute = 2DIGIT ; 00-59
|d = 2006-01-01T00:60:00-00:00
|""".stripMargin)

assert(result.isLeft)
}

test("time-no-leads") {
val result = arktekk.jz2024.toml.toml.parseAll("""# Leading 0 is always required.
val result = arktekk.oppgave3.toml.parseAll("""# Leading 0 is always required.
|d = 2023-10-01T1:32:00Z
|""".stripMargin)

assert(result.isLeft)
}

test("no-leads-month") {
val result = arktekk.jz2024.toml.toml.parseAll("""# Month "7" instead of "07"; the leading zero is required.
val result = arktekk.oppgave3.toml.parseAll("""# Month "7" instead of "07"; the leading zero is required.
|no-leads = 1987-7-05T17:45:00Z
|""".stripMargin)

assert(result.isLeft)
}

test("mday-under") {
val result = arktekk.jz2024.toml.toml.parseAll("""# date-mday = 2DIGIT ; 01-28, 01-29, 01-30, 01-31 based on
val result = arktekk.oppgave3.toml.parseAll("""# date-mday = 2DIGIT ; 01-28, 01-29, 01-30, 01-31 based on
|# ; month/year
|d = 2006-01-00T00:00:00-00:00
|""".stripMargin)
Expand All @@ -88,31 +88,31 @@ class DatetimeInvalid extends AnyFunSuite {
}

test("hour-over") {
val result = arktekk.jz2024.toml.toml.parseAll("""# time-hour = 2DIGIT ; 00-23
val result = arktekk.oppgave3.toml.parseAll("""# time-hour = 2DIGIT ; 00-23
|d = 2006-01-01T24:00:00-00:00
|""".stripMargin)

assert(result.isLeft)
}

test("no-leads") {
val result = arktekk.jz2024.toml.toml.parseAll("""# Month "7" instead of "07"; the leading zero is required.
val result = arktekk.oppgave3.toml.parseAll("""# Month "7" instead of "07"; the leading zero is required.
|no-leads = 1987-7-05T17:45:00Z
|""".stripMargin)

assert(result.isLeft)
}

test("feb-29") {
val result = arktekk.jz2024.toml.toml.parseAll(""""not a leap year" = 2100-02-29T15:15:15Z
val result = arktekk.oppgave3.toml.parseAll(""""not a leap year" = 2100-02-29T15:15:15Z
|""".stripMargin)

assert(result.isLeft)
}

test("second-over") {
val result =
arktekk.jz2024.toml.toml.parseAll("""# time-second = 2DIGIT ; 00-58, 00-59, 00-60 based on leap second
arktekk.oppgave3.toml.parseAll("""# time-second = 2DIGIT ; 00-58, 00-59, 00-60 based on leap second
|# ; rules
|d = 2006-01-01T00:00:61-00:00
|""".stripMargin)
Expand All @@ -121,7 +121,7 @@ class DatetimeInvalid extends AnyFunSuite {
}

test("mday-over") {
val result = arktekk.jz2024.toml.toml.parseAll("""# date-mday = 2DIGIT ; 01-28, 01-29, 01-30, 01-31 based on
val result = arktekk.oppgave3.toml.parseAll("""# date-mday = 2DIGIT ; 01-28, 01-29, 01-30, 01-31 based on
|# ; month/year
|d = 2006-01-32T00:00:00-00:00
|""".stripMargin)
Expand All @@ -130,15 +130,15 @@ class DatetimeInvalid extends AnyFunSuite {
}

test("offset-overflow-hour") {
val result = arktekk.jz2024.toml.toml.parseAll("""# Hour must be 00-24
val result = arktekk.oppgave3.toml.parseAll("""# Hour must be 00-24
|d = 1985-06-18 17:04:07+25:00
|""".stripMargin)

assert(result.isLeft)
}

test("month-over") {
val result = arktekk.jz2024.toml.toml.parseAll("""# date-month = 2DIGIT ; 01-12
val result = arktekk.oppgave3.toml.parseAll("""# date-month = 2DIGIT ; 01-12
|d = 2006-13-01T00:00:00-00:00
|""".stripMargin)

Expand Down
Loading

0 comments on commit cb4613a

Please sign in to comment.