-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from morgen-peschke/release.0.1.0
Release.0.1.0
- Loading branch information
Showing
20 changed files
with
1,367 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/sh | ||
|
||
if git rev-parse --verify HEAD >/dev/null 2>&1 | ||
then | ||
against=HEAD | ||
else | ||
# Initial commit: diff against an empty tree object | ||
against=$(git hash-object -t tree /dev/null) | ||
fi | ||
|
||
# Redirect output to stderr. | ||
exec 1>&2 | ||
|
||
# Cross platform projects tend to avoid non-ASCII filenames; prevent | ||
# them from being added to the repository. We exploit the fact that the | ||
# printable range starts at the space character and ends with tilde. | ||
# | ||
# Note that the use of brackets around a tr range is ok here, (it's | ||
# even required, for portability to Solaris 10's /usr/bin/tr), since | ||
# the square bracket bytes happen to fall in the designated range. | ||
if test $(git diff --cached --name-only --diff-filter=A -z $against | | ||
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 | ||
then | ||
cat <<\EOF | ||
Error: Attempt to add a non-ASCII file name. | ||
This can cause problems if you want to work with people on other platforms. | ||
To be portable it is advisable to rename the file. | ||
EOF | ||
exit 1 | ||
fi | ||
|
||
mill __.compile + \ | ||
__.test + \ | ||
__.checkFormat |
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 |
---|---|---|
|
@@ -3,4 +3,7 @@ | |
target/ | ||
*~ | ||
.idea | ||
out | ||
out | ||
.DS_Store | ||
.bsp | ||
project |
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
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 |
---|---|---|
@@ -1,7 +1,21 @@ | ||
package peschke | ||
|
||
import org.scalatest.OptionValues | ||
import org.scalacheck.Shrink | ||
import org.scalatest.{EitherValues, OptionValues} | ||
import org.scalatest.matchers.must.Matchers | ||
import org.scalatest.prop.TableDrivenPropertyChecks | ||
import org.scalatest.wordspec.AnyWordSpec | ||
import org.scalatest.propspec.AnyPropSpec | ||
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks | ||
|
||
trait UnitSpec extends AnyWordSpec with Matchers with OptionValues | ||
trait CommonSpec extends Matchers with EitherValues with OptionValues | ||
|
||
trait UnitSpec extends AnyWordSpec with CommonSpec | ||
|
||
trait PropSpec extends AnyPropSpec with CommonSpec with ScalaCheckDrivenPropertyChecks { | ||
implicit def noShrink[T]: Shrink[T] = Shrink.shrinkAny | ||
} | ||
|
||
trait TableSpec extends AnyWordSpec with CommonSpec with TableDrivenPropertyChecks { | ||
implicit def noShrink[T]: Shrink[T] = Shrink.shrinkAny | ||
} |
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,79 @@ | ||
package peschke.python | ||
|
||
import cats.syntax.all._ | ||
|
||
/** Represent a Python slice in Scala | ||
*/ | ||
sealed abstract class Slice extends Product with Serializable { | ||
def startOpt: Option[Long] = this match { | ||
case Slice.All(_) => none | ||
case Slice.FromStart(_, _) => none | ||
case Slice.ToEnd(start, _) => start.some | ||
case Slice.SubSlice(start, _, _) => start.some | ||
case Slice.At(index) => index.some | ||
} | ||
|
||
def endOpt: Option[Long] = this match { | ||
case Slice.All(_) => none | ||
case Slice.FromStart(end, _) => end.some | ||
case Slice.ToEnd(_, _) => none | ||
case Slice.SubSlice(_, end, _) => end.some | ||
case Slice.At(index) => (index + 1L).some | ||
} | ||
def step: Long | ||
} | ||
object Slice { | ||
def apply(startOpt: Option[Long], endOpt: Option[Long], stepOpt: Option[Long]) | ||
: Slice = { | ||
val step = stepOpt.getOrElse(1L) | ||
(startOpt, endOpt) match { | ||
case (Some(start), Some(end)) => SubSlice(start, end, step) | ||
case (Some(start), None) => ToEnd(start, step) | ||
case (None, None) => All(step) | ||
case (None, Some(end)) => FromStart(end, step) | ||
} | ||
} | ||
|
||
/** Equivalent to: | ||
* {{{ | ||
* [:] | ||
* [::] | ||
* [::step] | ||
* }}} | ||
*/ | ||
final case class All(step: Long) extends Slice | ||
|
||
/** Equivalent to: | ||
* {{{ | ||
* [:end] | ||
* [:end:] | ||
* [:end:step] | ||
* }}} | ||
*/ | ||
final case class FromStart(end: Long, step: Long) extends Slice | ||
|
||
/** Equivalent to: | ||
* {{{ | ||
* [start:] | ||
* [start::] | ||
* [start::step] | ||
* }}} | ||
*/ | ||
final case class ToEnd(start: Long, step: Long) extends Slice | ||
|
||
/** Equivalent to: | ||
* {{{ | ||
* [start:end:slice] | ||
* }}} | ||
*/ | ||
final case class SubSlice(start: Long, end: Long, step: Long) extends Slice | ||
|
||
/** Equivalent to: | ||
* {{{ | ||
* [index] | ||
* }}} | ||
*/ | ||
final case class At(index: Long) extends Slice { | ||
override def step: Long = 1L | ||
} | ||
} |
Oops, something went wrong.