Created
June 11, 2016 13:24
-
-
Save hibnico/80a81f8260e5f19a064c01a7ad6339f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use "debug" | |
| interface box Runner[A, R] | |
| fun apply(args: A): R^ | |
| interface box Generator[A] | |
| fun apply(): A^ | |
| interface box Property[R] | |
| fun apply(r: R): Bool | |
| class Checker[A, R] | |
| fun check(r: Runner[A, R], argsGenerator: Generator[A], prop: Property[R]) ? => | |
| let res = r.apply(argsGenerator.apply()) | |
| if not prop.apply(consume res) then | |
| error | |
| end | |
| primitive Addition | |
| fun add(x: U32, y: U32) : U64 => | |
| x.u64() + y.u64() | |
| actor Main | |
| new create(env: Env) => | |
| let runner = lambda (a: (U32,U32)): U64 => Addition.add(a._1,a._2) end | |
| let generator = lambda (): (U32,U32) => (1,2) end | |
| let property = lambda (r: U64): Bool => r == 3 end | |
| try | |
| Checker[(U32,U32), U64].create().check(runner, generator, property) | |
| Debug.out("OK!") | |
| else | |
| Debug.out("hum?") | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment