Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
phearnot committed Sep 27, 2024
1 parent 87c09d1 commit b2c4f9c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ class Parser(stdLibVersion: StdLibVersion)(implicit offset: LibrariesOffset) {
def unusedText[A: P] = comment ~ directive ~ comment

def escapedUnicodeSymbolP[A: P]: P[(Int, String, Int)] = P(Index ~~ (NoCut(unicodeSymbolP) | specialSymbols).! ~~ Index)
def escapedUnicodeOrEndOfString[A: P]: P[Any] = escapedUnicodeSymbolP[A] | notEndOfString
def stringP[A: P]: P[EXPR] =
P(Index ~~ "\"" ~/ Pass ~~ (escapedUnicodeSymbolP | notEndOfString).!.repX ~~ "\"" ~~ Index)
P(Index ~~ "\"" ~/ Pass ~~ (escapedUnicodeOrEndOfString).!.repX ~~ "\"" ~~ Index)
.map { case (start, xs, end) =>
var errors = Vector.empty[String]
val consumedString = new StringBuilder
Expand Down Expand Up @@ -255,9 +256,9 @@ class Parser(stdLibVersion: StdLibVersion)(implicit offset: LibrariesOffset) {
def funcBody = singleBaseExpr
def correctFunc = Index ~~ funcKWAndName ~ comment ~/ args(min = 0) ~ ("=" ~ funcBody | "=" ~/ Fail.opaque("function body")) ~~ Index
def noKeyword = {
def noArgs = "(" ~ comment ~ ")" ~ comment
def validName = NoCut(funcName).filter(_.isInstanceOf[VALID[?]])
def argsOrEqual = (NoCut(args(min = 1)) ~ "=".?) | (noArgs ~ "=" ~~ !"=")
def noArgs = "(" ~ comment ~ ")" ~ comment
def validName = NoCut(funcName).filter(_.isInstanceOf[VALID[?]])
def argsOrEqual: P[Any] = (NoCut(args(min = 1)) ~ "=".?) | (noArgs ~ "=" ~~ !"=")
(validName ~ comment ~ argsOrEqual ~/ funcBody.? ~~ Fail)
.asInstanceOf[P[Nothing]]
.opaque(""""func" keyword""")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ class SyncDAppComplexityCountTest extends PropSpec with WithDomain {
val expectedPortfolios = if (exceeding || raiseError) basePortfolios else basePortfolios |+| additionalPortfolios
expectedPortfolios
.foreach { case (address, expectedPortfolio) =>
expectedPortfolio.balance shouldBe snapshot.balances.get((address, Waves)).map(_ - db.balance(address)).getOrElse(0)
expectedPortfolio.balance shouldBe snapshot.balances.get((address, Waves)).map(_ - db.balance(address)).getOrElse(0L)
expectedPortfolio.assets.foreach { case (asset, balance) =>
balance shouldBe snapshot.balances.get((address, asset)).map(_ - db.balance(address, asset)).getOrElse(0)
balance shouldBe snapshot.balances.get((address, asset)).map(_ - db.balance(address, asset)).getOrElse(0L)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class CommonFunctionsTest extends PropSpec {
TxHelpers.issue(version = TxVersion.V1),
createMassTransfer()
).foreach { tx =>
Try[Either[String, ?]] {
Try {
runScript(
s"""
|let t = 100
Expand All @@ -153,7 +153,7 @@ class CommonFunctionsTest extends PropSpec {
|""".stripMargin,
Coproduct(tx)
)
}.recover {
}.recover[Any] {
case ex: MatchError =>
Assertions.assert(ex.getMessage().contains("Compilation failed: Value 't' already defined in the scope"))
case _: Throwable => Assertions.fail("Some unexpected error")
Expand All @@ -171,7 +171,7 @@ class CommonFunctionsTest extends PropSpec {
| }
|""".stripMargin
)
}.recover {
}.recover[Any] {
case ex: MatchError => Assertions.assert(ex.getMessage().contains("Compilation failed: A definition of 'p' is not found"))
case _: Throwable => Assertions.fail("Some unexpected error")
}
Expand Down Expand Up @@ -274,7 +274,7 @@ class CommonFunctionsTest extends PropSpec {
(s"Addr(base58'$realAddr')", "Can't find a function 'Addr'")
)
for ((clause, err) <- cases) {
Try[Either[String, ?]] {
Try {
runScript(
s"""
|match tx {
Expand All @@ -285,7 +285,7 @@ class CommonFunctionsTest extends PropSpec {
|}
|""".stripMargin
)
}.recover {
}.recover[Any] {
case ex: MatchError => Assertions.assert(ex.getMessage().contains(err))
case e: Throwable => Assertions.fail("Unexpected error", e)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class EthereumTransactionSpec
val assetTransfer = EthTxGenerator.generateEthTransfer(senderAccount, recipientAddress, Long.MaxValue, TestAsset)

differ(assetTransfer).balances shouldBe Map(
(senderAddress, TestAsset) -> 0,
(senderAddress, TestAsset) -> 0L,
(senderAddress, Waves) -> (LongMaxMinusFee + transfer.fee.longValue()),
(recipientAddress, TestAsset) -> Long.MaxValue
)
Expand Down

0 comments on commit b2c4f9c

Please sign in to comment.