Permalink
Browse files

major refactoring, README not yet updated

User-visible changes:
* Minor changes in return value format.
* Impemented opaque data type for counterexamples that contains
  all information necessary for rerunning counterexamples, plus
  functions that extract the interesting parts for the user.
* The most recent counterexample can now be retrieved after the
  conclusion of a test.
* Mismatch between format of variables and types in ?FORALLs now
  results in an error message instead of crashing the program.
* Counterexamples can now carry stacktraces.
* New options: to_file, on_output, long_result, start_size, noshrink,
  plus a change in the effect of 'quiet'.
* proper_types:is_instance(X,Type) is now part of the public interface.
* Implemented aggregate/2, on_output/2 test wrappers.
* Better statistics printing.
* Removed unneeded macro version of some wrappers.

Internal changes:
* Cleaned up Makefile.
* Cleaner use of 'size' parameter.
* 'crypto' module now actually used in the generation of binaries.
* Fixed a bug in the random function generator.
* AND3 and OR3 are now lazy, this fixes a bug in instance testing.
* Better growing behaviour and smarter shrinking for numbers.
* 'opts()' record no longer exported from main module.
* Cleaner use of process dictionary (mainly inside proper_gen).
* Added unit tests, contained in tests/proper_tests.erl, powered by
  EUnit - compile with 'make tests' ('eunit' application required),
  run with 'make test'.
  • Loading branch information...
1 parent 888e261 commit 0c9af8ec2d1d467923abe2588c10c227e417284a @manopapad committed Jun 30, 2010
Showing with 1,332 additions and 785 deletions.
  1. +24 −19 Makefile
  2. +4 −4 README
  3. +3 −1 include/proper.hrl
  4. +1 −3 include/proper_common.hrl
  5. +8 −2 include/proper_internal.hrl
  6. +420 −309 src/proper.erl
  7. +31 −15 src/proper_arith.erl
  8. +2 −1 src/proper_extra.erl
  9. +128 −73 src/proper_gen.erl
  10. +83 −92 src/proper_shrink.erl
  11. +6 −2 src/proper_symb.erl
  12. +45 −40 src/proper_types.erl
  13. +577 −224 tests/proper_tests.erl
View
@@ -8,27 +8,27 @@ TST_BIN_DIR=tests
EXM_DIR=examples
TMP_PATTERN=*~ \\\#*\\\# *.dump
-APP_MODULES=proper proper_types proper_gen proper_symb proper_shrink proper_arith proper_extra
-HEADERS=proper proper_internal proper_common
-TST_MODULES=proper_tests
-EXM_MODULES=mm
TXT_FILES=COPYING Makefile README $(DOC_DIR)/overview.edoc
RELEASE_FILE=proper.tar.gz
-APP_SRC_FILES=$(addprefix $(APP_SRC_DIR)/, $(addsuffix .erl, $(APP_MODULES)))
-APP_BIN_FILES=$(addprefix $(APP_BIN_DIR)/, $(addsuffix .beam, $(APP_MODULES)))
-HDR_FILES=$(addprefix $(HDR_DIR)/, $(addsuffix .hrl, $(HEADERS)))
+APP_SRC_FILES=$(wildcard $(APP_SRC_DIR)/*.erl)
+APP_MODULES=$(APP_SRC_FILES:$(APP_SRC_DIR)/%.erl=%)
+APP_BIN_FILES=$(APP_MODULES:%=$(APP_BIN_DIR)/%.beam)
+HDR_FILES=$(wildcard $(HDR_DIR)/*.hrl)
DOC_FILES=$(addprefix $(DOC_DIR)/, $(DOC_PATTERN) $(addsuffix .html, $(APP_MODULES)))
-TST_SRC_FILES=$(addprefix $(TST_SRC_DIR)/, $(addsuffix .erl, $(TST_MODULES)))
-TST_BIN_FILES=$(addprefix $(TST_BIN_DIR)/, $(addsuffix .beam, $(TST_MODULES)))
-EXM_FILES=$(addprefix $(EXM_DIR)/, $(addsuffix .erl, $(EXM_MODULES)))
+TST_SRC_FILES=$(wildcard $(TST_SRC_DIR)/*.erl)
+TST_MODULES=$(TST_SRC_FILES:$(TST_SRC_DIR)/%.erl=%)
+TST_BIN_FILES=$(TST_MODULES:%=$(TST_BIN_DIR)/%.beam)
+EXM_FILES=$(wildcard $(EXM_DIR)/*.erl)
TMP_FILES=$(TMP_PATTERN) $(addprefix $(APP_SRC_DIR)/, $(TMP_PATTERN)) $(addprefix $(HDR_DIR)/, $(TMP_PATTERN)) $(addprefix $(DOC_DIR)/, $(TMP_PATTERN)) $(addprefix $(TST_SRC_DIR)/, $(TMP_PATTERN)) $(addprefix $(EXM_DIR)/, $(TMP_PATTERN))
-ENTER_ERL=erl -noinput -eval '
-EXIT_ERL=, halt().'
+ENTER_ERL=erl -noinput -pa $(APP_BIN_DIR) -eval '
+EXIT_ERL=' -run init stop
ERLC=erlc
-ERLC_FLAGS=-W2 -Ddebug -DTEST +debug_info +warn_missing_spec +warn_untyped_record +inline -I $(HDR_DIR)
+APP_ERLC_FLAGS=-W2 -Ddebug +debug_info +warn_missing_spec +warn_untyped_record -I $(HDR_DIR)
+TST_ERLC_FLAGS=-W2 +debug_info +nowarn_unused_function -I $(HDR_DIR)
EDOC_OPTIONS=[{dialyzer_specs,all}, {report_missing_type,true}, {report_type_mismatch,true}, {pretty_print,erl_pp}, {preprocess,true}]
+EUNIT_OPTIONS=[]
DIALYZER=dialyzer
DIALYZER_FLAGS=-Wunmatched_returns
NEEDED_APPS=compiler erts kernel stdlib crypto
@@ -40,37 +40,42 @@ TAR=tar -czf
# TODO: extra targets: test, tags, commit/update
# TODO: header and text files as dependencies: more fine-grained
-.PHONY: default all compile tests doc check clean distclean rebuild release build_plt
+.PHONY: default all compile tests doc test check clean distclean rebuild release build_plt
default: compile
-all: compile tests doc
+all: compile doc
compile: $(APP_BIN_FILES)
$(APP_BIN_FILES): $(HDR_FILES)
$(APP_BIN_DIR)/%.beam: $(APP_SRC_DIR)/%.erl
- $(ERLC) $(ERLC_FLAGS) -o $(APP_BIN_DIR) $<
+ $(ERLC) $(APP_ERLC_FLAGS) -o $(APP_BIN_DIR) $<
tests: $(TST_BIN_FILES)
$(TST_BIN_FILES): $(HDR_FILES)
$(TST_BIN_DIR)/%.beam: $(TST_SRC_DIR)/%.erl
- $(ERLC) $(ERLC_FLAGS) -o $(TST_BIN_DIR) $<
+ $(ERLC) $(TST_ERLC_FLAGS) -o $(TST_BIN_DIR) $<
doc: $(APP_SRC_FILES) $(HDR_FILES) $(TXT_FILES)
$(ENTER_ERL) edoc:application(proper, ".", $(EDOC_OPTIONS)) $(EXIT_ERL)
+test: tests
+ $(ENTER_ERL) eunit:test({dir,"$(TST_BIN_DIR)"},$(EUNIT_OPTIONS)) $(EXIT_ERL)
+
check: compile
$(DIALYZER) $(DIALYZER_FLAGS) $(APP_BIN_FILES)
clean:
- $(RM) $(TMP_FILES)
+ @echo removing temporary files...
+ @$(RM) $(TMP_FILES)
distclean: clean
- $(RM) $(APP_BIN_FILES) $(DOC_FILES) $(TST_BIN_FILES) $(RELEASE_FILE)
+ @echo removing build artifacts...
+ @$(RM) $(APP_BIN_FILES) $(DOC_FILES) $(TST_BIN_FILES) $(RELEASE_FILE)
rebuild: distclean compile
View
8 README
@@ -64,7 +64,7 @@ wrapping such a boolean expression with one or more of the following wrappers:
rejected (it doesn't count as a failing test case), and PropEr starts over
with a new random test case. Also, in verbose mode, an 'x' is printed on
screen.
-collect(<Category>, <Prop>) or ?COLLECT(<Category>, <Prop>)
+collect(<Category>, <Prop>)
The <Category> field can be an expression or statement block that evaluates
to any term - the test case produced will be categorized under this term.
All produced categories are printed at the end of testing (in case no test
@@ -96,9 +96,9 @@ equals(<A>, <B>)
Additionally, a property may be wrapped with one or more of the following
outer-level wrappers, which control the behaviour of the testing subsystem:
-numtests(<Positive_number>, <Prop>) or ?NUMTESTS(<Positive_number>, <Prop>)
+numtests(<Positive_number>, <Prop>)
Specifies the number of tests to run. Default is 100.
-fails(<Prop>) or ?FAILS(<Prop>)
+fails(<Prop>)
Specifies that we expect the property to fail for some input. The property
will be considered failing if it passes all the tests.
@@ -145,7 +145,7 @@ available options are:
Specifies the maximum number of times a failing test case should be shrunk
before returning. Note that the shrinking may stop before so many shrinks
are achieved if the shrinking subsystem deduces that it cannot shrink the
- failing test case further. Default is 300.
+ failing test case further. Default is 500.
{'constraint_tries', <Positive_number>}
Specifies the maximum number of tries before the generator subsystem gives
up on producing an instance that satisfies a ?SUCHTHAT constraint. Default
View
@@ -1,4 +1,5 @@
%%% Copyright 2010 Manolis Papadakis (manopapad@gmail.com)
+%%% and Kostis Sagonas (kostis@cs.ntua.gr)
%%%
%%% This file is part of PropEr.
%%%
@@ -26,7 +27,8 @@
%% Test generation functions
%%------------------------------------------------------------------------------
--import(proper, [numtests/2, collect/2, fails/1, equals/2]).
+-import(proper, [numtests/2, collect/2, aggregate/2, fails/1, on_output/2,
+ equals/2]).
%%------------------------------------------------------------------------------
@@ -1,4 +1,5 @@
%%% Copyright 2010 Manolis Papadakis (manopapad@gmail.com)
+%%% and Kostis Sagonas (kostis@cs.ntua.gr)
%%%
%%% This file is part of PropEr.
%%%
@@ -24,10 +25,7 @@
-define(FORALL(X,RawType,Prop), {'$forall',RawType,fun(X) -> Prop end}).
-define(IMPLIES(Pre,Prop), {'$implies',Pre,?DELAY(Prop)}).
--define(COLLECT(Category,Prop), {'$collect',Category,Prop}).
-define(WHENFAIL(Action,Prop), {'$whenfail',?DELAY(Action),?DELAY(Prop)}).
--define(NUMTESTS(N,Test), {'$numtests',N,Test}).
--define(FAILS(Test), {'$fails',Test}).
-define(TRAPEXIT(Prop), {'$trapexit',?DELAY(Prop)}).
-define(TIMEOUT(Limit,Prop), {'$timeout',Limit,?DELAY(Prop)}).
%% TODO: -define(ALWAYS(Tests,Prop), {'$always',Tests,?DELAY(Prop)}).
@@ -26,14 +26,20 @@
%% Constants
%%------------------------------------------------------------------------------
-%% TODO: make some of these into parameters, store them in process registry
--define(MAX_RANDOM_TRIES_WHEN_SHRINKING, 5).
-define(MAX_LIST_LEN, 200).
-define(MAX_ATOM_LEN, 255).
-define(MAX_BINARY_LEN, 300).
-define(SEED_RANGE, 4294967296).
+%%------------------------------------------------------------------------------
+%% Macros
+%%------------------------------------------------------------------------------
+
+-define(AND3(X,Y), proper_arith:and3(?DELAY(X),?DELAY(Y))).
+-define(OR3(X,Y), proper_arith:or3(?DELAY(X),?DELAY(Y))).
+
+
%%------------------------------------------------------------------------------
%% Common type aliases
%%------------------------------------------------------------------------------
Oops, something went wrong.

0 comments on commit 0c9af8e

Please sign in to comment.