Test a function: Difference between revisions

Add bruijn
m (→‎{{header|Wren}}: Minor tidy)
(Add bruijn)
 
Line 209:
 
4 tests, 4 assertions, 1 failures.</pre>
 
=={{header|Bruijn}}==
Bruijn has equivalency testing builtin. The <code>:test</code> instruction checks whether two terms are beta-equivalent (alpha-equivalent after beta-reduction) and prints an error if they aren't. Alpha-conversion is not needed because of the usage of De Bruijn indices. All tests in imported files get run automatically (can be disabled using a CLI flag).
<syntaxhighlight lang="bruijn">
:import std/String .
 
main [<~>0 =? 0]
 
:test (main "tacocat") ([[1]])
:test (main "bruijn") ([[1]])
</syntaxhighlight>
 
{{out}}
<pre>
ERROR test failed: (main [((0 [[[(0 (1 (0 (0 (0 (1 (1 (0 2))))))))]]]) [((0 [[[(0 (1 (0 (0 (1 (1 (1 (0 2))))))))]]]) [((0 [[[(1 (0 (1 (0 (1 (1 (1 (0 2))))))))]]]) [((0 [[[(1 (0 (0 (1 (0 (1 (1 (0 2))))))))]]]) [((0 [[[(0 (1 (0 (1 (0 (1 (1 (0 2))))))))]]]) [((0 [[[(0 (1 (1 (1 (0 (1 (1 (0 2))))))))]]]) [[0]])])])])])])]) = [[1]]
reduced to [[0]] = [[1]]
</pre>
 
=={{header|C}}==
55

edits