Skip to content

Instantly share code, notes, and snippets.

@StoneCypher
Created February 2, 2014 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StoneCypher/8775865 to your computer and use it in GitHub Desktop.
Save StoneCypher/8775865 to your computer and use it in GitHub Desktop.
-module(dumb_math_tests).
-compile(export_all).
-include_lib("proper/include/proper.hrl").
-include_lib("eunit/include/eunit.hrl").
prop_square_never_negative() ->
?FORALL( Number, proper_types:number(), dumb_math:square(Number) >= 0 ).
square_test_() ->
{ "Square tests", [
{ "Zero", ?_assert( 0 =:= dumb_math:square(0) ) },
{ "Two", ?_assert( 4 =:= dumb_math:square(2) ) },
{ "Neg Two", ?_assert( 4 =:= dumb_math:square(-2) ) },
{ "One and a half", ?_assert( 2.25 =:= dumb_math:square(1.5) ) },
{"Stochastic: never negative", ?_assert( true =:= proper:quickcheck(prop_square_never_negative()) ) }
] }.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment