add arity testcase

This commit is contained in:
Matthew Griffith 2020-08-22 20:03:26 -04:00
parent 1c9f37c6f4
commit 569f63cfa1
5 changed files with 119 additions and 0 deletions

View File

@ -0,0 +1,46 @@
port module Main exposing (main)
{-| -}
import Benchmark exposing (..)
import Benchmark.Runner exposing (BenchmarkProgram, program)
import Benchmark.Runner.Json
import Dict
import Html
import Json.Decode
import Json.Encode
import List
main : Benchmark.Runner.Json.JsonBenchmark
main =
Benchmark.Runner.Json.program reportResults suite
port reportResults : Json.Encode.Value -> Cmd msg
type MyType
= Zero
| One Int
| Two String String
{-| This is an interesting case becase the function be being applied both fully, and partially.
-}
weird : (Bool -> MyType -> Bool) -> ( MyType, List MyType ) -> List Bool
weird fn ( top, remaining ) =
fn True top :: List.map (fn False) remaining
alwaysFalse one two =
False
suite : Benchmark
suite =
describe "Arity"
[ benchmark "Passed function being used fully and partially" <|
\_ ->
weird alwaysFalse ( Zero, [ Zero, Zero, Zero ] )
]

View File

@ -0,0 +1,30 @@
{
"type": "application",
"source-directories": [
".",
"../benchmark-utilities"
],
"elm-version": "0.19.1",
"dependencies": {
"direct": {
"BrianHicks/elm-trend": "2.1.3",
"elm/browser": "1.0.2",
"elm/core": "1.0.5",
"elm/html": "1.0.0",
"elm/json": "1.1.3",
"elm-explorations/benchmark": "1.0.1"
},
"indirect": {
"Skinney/murmur3": "2.0.8",
"elm/regex": "1.0.0",
"elm/time": "1.0.0",
"elm/url": "1.0.0",
"elm/virtual-dom": "1.0.2",
"mdgriffith/style-elements": "5.0.1"
}
},
"test-dependencies": {
"direct": {},
"indirect": {}
}
}

View File

View File

@ -0,0 +1,22 @@
<html>
<head>
<meta charset="UTF-8" />
<title>Main</title>
<script src="output/elm.opt.js"></script>
</head>
<body>
<div id="myapp"></div>
<script>
var app = Elm.Main.init({
node: document.getElementById('myapp'),
});
window.results = [];
app.ports.reportResults.subscribe(function(message) {
window.results = message;
document.title = 'done';
});
</script>
</body>
</html>

View File

@ -0,0 +1,21 @@
<html>
<head>
<meta charset="UTF-8" />
<title>Main</title>
<script src="output/elm.opt.transformed.js"></script>
</head>
<body>
<div id="myapp"></div>
<script>
var app = Elm.Main.init({
node: document.getElementById('myapp'),
});
window.results = [];
app.ports.reportResults.subscribe(function(message) {
window.results = message;
document.title = 'done';
});
</script>
</body>
</html>