mirror of
https://github.com/KarolS/millfork.git
synced 2025-01-26 20:33:02 +00:00
Fix parsing of zp_bytes
This commit is contained in:
parent
239d837f96
commit
1d825a0c99
@ -322,7 +322,7 @@ object Platform {
|
||||
if (segments.length != 2) {
|
||||
log.fatal(s"Invalid range: `$s`")
|
||||
}
|
||||
Range(parseNumber(segments(0).trim()), parseNumber(segments(1).trim()), step)
|
||||
Range(parseNumber(segments(0).trim()), parseNumber(segments(1).trim()) + 1, step)
|
||||
} else {
|
||||
Seq(parseNumber(s.trim()))
|
||||
}
|
||||
|
34
src/test/scala/millfork/NullLogger.scala
Normal file
34
src/test/scala/millfork/NullLogger.scala
Normal file
@ -0,0 +1,34 @@
|
||||
package millfork
|
||||
|
||||
import millfork.assembly.SourceLine
|
||||
import millfork.error.Logger
|
||||
import millfork.node.Position
|
||||
|
||||
/**
|
||||
* @author Karol Stasiak
|
||||
*/
|
||||
class NullLogger extends Logger {
|
||||
override def setFatalWarnings(fatalWarnings: Boolean): Unit = ()
|
||||
|
||||
override def info(msg: String, position: Option[Position]): Unit = ()
|
||||
|
||||
override def debug(msg: String, position: Option[Position]): Unit = ()
|
||||
|
||||
override def trace(msg: String, position: Option[Position]): Unit = ()
|
||||
|
||||
override def traceEnabled: Boolean = false
|
||||
|
||||
override def warn(msg: String, position: Option[Position]): Unit = ()
|
||||
|
||||
override def error(msg: String, position: Option[Position]): Unit = ()
|
||||
|
||||
override def fatal(msg: String, position: Option[Position]): Nothing = throw new RuntimeException
|
||||
|
||||
override def fatalQuit(msg: String, position: Option[Position]): Nothing = throw new RuntimeException
|
||||
|
||||
override def assertNoErrors(msg: String): Unit = ()
|
||||
|
||||
override def addSource(filename: String, lines: IndexedSeq[String]): Unit = ()
|
||||
|
||||
override def getLine(line: SourceLine): Option[String] = None
|
||||
}
|
29
src/test/scala/millfork/test/PlatformParsingSuite.scala
Normal file
29
src/test/scala/millfork/test/PlatformParsingSuite.scala
Normal file
@ -0,0 +1,29 @@
|
||||
package millfork.test
|
||||
|
||||
import millfork.error.Logger
|
||||
import millfork.{NullLogger, Platform}
|
||||
import org.scalatest.{AppendedClues, FunSuite, Matchers}
|
||||
|
||||
/**
|
||||
* @author Karol Stasiak
|
||||
*/
|
||||
class PlatformParsingSuite extends FunSuite with Matchers with AppendedClues {
|
||||
test("ranges in zp_bytes should be parsed correctly") {
|
||||
implicit val logger: Logger = new NullLogger()
|
||||
val b6to9 = Platform.parseNumberOrRange("6-9", 1)
|
||||
b6to9 shouldNot contain(5)
|
||||
b6to9 should contain(6)
|
||||
b6to9 should contain(7)
|
||||
b6to9 should contain(8)
|
||||
b6to9 should contain(9)
|
||||
b6to9 shouldNot contain(10)
|
||||
val p6to9 = Platform.parseNumberOrRange("6-9", 2)
|
||||
p6to9 shouldNot contain(5)
|
||||
p6to9 should contain(6)
|
||||
p6to9 shouldNot contain(7)
|
||||
p6to9 should contain(8)
|
||||
p6to9 shouldNot contain(9)
|
||||
p6to9 shouldNot contain(10)
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user