Merge pull request #90 from miniBill/shexception

Add testcase for the exception in SHA256
This commit is contained in:
Matthew Griffith 2022-03-24 11:37:57 -04:00 committed by GitHub
commit 0f777a4f74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 3 deletions

View File

@ -8,13 +8,17 @@
"direct": {
"elm/browser": "1.0.2",
"elm/core": "1.0.5",
"elm/html": "1.0.0"
"elm/html": "1.0.0",
"folkertdev/elm-sha2": "1.0.0"
},
"indirect": {
"danfishgold/base64-bytes": "1.1.0",
"elm/bytes": "1.0.8",
"elm/json": "1.1.3",
"elm/time": "1.0.0",
"elm/url": "1.0.0",
"elm/virtual-dom": "1.0.2"
"elm/virtual-dom": "1.0.2",
"rtfeldman/elm-hex": "1.0.0"
}
},
"test-dependencies": {

View File

@ -1,3 +1,8 @@
#/bin/sh
# Stop execution if a command fails
set -ex
# The main goal here is to have some guarantee that the transformed elm code functions as normally.
# Compile normally
@ -10,4 +15,4 @@ elm make src/Tests.elm --output=dist/elm.js --optimize
../../bin/elm-optimize-level-2 --output=dist/elm-lvl-3.js -O3 src/Tests.elm
# Run tests
node index.js
node index.js

View File

@ -1,5 +1,7 @@
port module Tests exposing (..)
import SHA256
main : Program {} () ()
main =
@ -32,6 +34,7 @@ suite =
describe "Tests for js code replacements"
[ list
, string
, sha2
]
@ -57,6 +60,7 @@ run testcase =
)
[]
tests
|> List.map (\failure -> name ++ " -> " ++ failure)
test =
@ -125,3 +129,13 @@ string =
"nananananananananana"
== String.repeat 10 "na"
]
sha2 : Test
sha2 =
describe "Sha 2"
[ test "sha256(\"Input\") == \"36ecb4f8669133ce744c21982ba4abe2ecd7086e1dc2226ccd6f266f3a5005f8\"" <|
\_ ->
SHA256.toHex (SHA256.fromString "Input")
== "36ecb4f8669133ce744c21982ba4abe2ecd7086e1dc2226ccd6f266f3a5005f8"
]