Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rsoeldner committed Jul 10, 2024
1 parent b097366 commit 78c2b65
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 32 deletions.
32 changes: 2 additions & 30 deletions pact-tests/Pact/Core/Test/DocsTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import qualified Data.Set as S
import Data.Text (Text)
import qualified Data.Text as T
import Pact.Core.Builtin
import Paths_pact_tng
import Pact.Core.Repl.BuiltinDocs.Internal
import System.Directory
import System.FilePath
import Test.Tasty
Expand All @@ -24,7 +24,7 @@ tests = do

docsExistsTest :: [Text] -> TestTree
docsExistsTest b = testCase "Builtins should have docs" $ do
let normBuiltins = normalizeBuiltinName <$> replCoreBuiltinNames
let normBuiltins = builtinToNormalizedName <$> replCoreBuiltinNames
let diff = (S.fromList normBuiltins `S.difference` excluded) `S.difference` S.fromList b
assertEqual "Missing builtins should be empty" S.empty diff
where
Expand All @@ -34,31 +34,3 @@ docsExistsTest b = testCase "Builtins should have docs" $ do
,"env-set-milligas", "env-stackframe", "env-verifiers", "negate"
,"pact-state", "print", "reset-pact-state", "rollback-tx", "show"
,"sig-keyset", "test-capability"]

normalizeBuiltinName :: Text -> Text
normalizeBuiltinName = \case
"!=" -> "neq"
"&" -> "and"
"*" -> "mult"
"+" -> "add"
"-" -> "sub"
"/" -> "div"
"<" -> "lt"
"<=" -> "leq"
"=" -> "eq"
">" -> "gt"
">=" -> "geq"
"^" -> "pow"
"and?" -> "and-q"
"not?" -> "not-q"
"or?" -> "or-q"
"|" -> "bitwise-or"
"~" -> "bitwise-reverse"
"begin-named-tx" -> "begin-tx"
"continue-pact-rollback-yield" -> "continue-pact"
"continue-pact-rollback-yield-object" -> "continue-pact"
"continue-pact-with-rollback" -> "continue-pact"
"enforce-pact-version-range" -> "enforce-pact-version"
"env-set-gas" -> "env-gas"
"expect-failure-match" -> "expect-failure"
other -> other
4 changes: 2 additions & 2 deletions pact/Pact/Core/Repl/BuiltinDocs/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ mkBuiltinDocs = embedIO action
builtinToNormalizedName :: T.Text -> T.Text
builtinToNormalizedName = \case
"!=" -> "neq"
"&" -> "and"
"&" -> "bitwise-and"
"*" -> "mult"
"+" -> "add"
"-" -> "sub"
Expand Down Expand Up @@ -77,7 +77,7 @@ builtinToNormalizedName = \case
normalizedNameToBuiltin :: T.Text -> T.Text
normalizedNameToBuiltin = \case
"neq" -> "!="
"and" -> "&"
"bitwise-and" -> "&"
"mult" -> "*"
"add" -> "+"
"sub" -> "-"
Expand Down

0 comments on commit 78c2b65

Please sign in to comment.