@@ -0,0 +1,65 @@
1+module Realistic.Check (benchmark) where
2+{-| Source: http://elm-lang.org/examples/checkboxes
3+-}
4+
5+import Benchmark
6+import String
7+
8+
9+benchmark : Benchmark.Benchmark
10+benchmark =
11+ Benchmark.suite "check box business logic"
12+ [ run "toggle boxes" toggleActions
13+ ]
14+
15+
16+run : String -> List Action -> Benchmark.Benchmark
17+run description actions =
18+ Benchmark.test
19+ (description ++ " - " ++ toString (List.length actions) ++ " actions")
20+ (\_ -> List.foldl update initialModel actions)
21+
22+
23+toggleActions =
24+ [ Red True
25+ , Underline True
26+ , Bold True
27+ , Bold False
28+ , Red False
29+ , Bold True
30+ , Bold False
31+ ]
32+
33+
34+-- MODEL
35+
36+type alias Model =
37+ { red : Bool
38+ , underline : Bool
39+ , bold : Bool
40+ }
41+
42+
43+initialModel =
44+ Model False False True
45+
46+
47+-- UPDATE
48+
49+type Action
50+ = Red Bool
51+ | Underline Bool
52+ | Bold Bool
53+
54+
55+update action model =
56+ case action of
57+ Red bool ->
58+ { model | red = bool }
59+
60+ Underline bool ->
61+ { model | underline = bool }
62+
63+ Bold bool ->
64+ { model | bold = bool }
65+