[m-rev.] diff: fix quickcheck

Tyson Dowd trd at cs.mu.OZ.AU
Mon Jul 30 23:44:33 AEST 2001


Hi,

I used quickcheck in the ICFP competition, so I make a few changes while
there.

===================================================================


Estimated hours taken: 1.0
Branches: main

extras/quickcheck/qcheck.m:
	Fix qcheck to work with the current time structure that
	time__localtime returns.

extras/quickcheck/Mmakefile:
extras/quickcheck/test_qcheck.m:
extras/quickcheck/nrev.m:
	Add a makefile and a simple testcase for qcheck.


Index: extras/quickcheck/Mmakefile
===================================================================
RCS file: Mmakefile
diff -N Mmakefile
--- /dev/null	Mon Apr 16 11:57:05 2001
+++ Mmakefile	Mon Jul 30 23:18:45 2001
@@ -0,0 +1,17 @@
+#-----------------------------------------------------------------------------#
+# Copyright (C) 2001 The University of Melbourne.
+# This file may only be copied under the terms of the GNU Library General
+# Public License - see the file COPYING.LIB in the Mercury distribution.
+#-----------------------------------------------------------------------------#
+
+-include ../Mmake.params
+
+MAIN_TARGET = all
+
+all:	test_qcheck
+
+depend:	test_qcheck.depend
+
+.PHONY: check
+check:
+	true
Index: extras/quickcheck/nrev.m
===================================================================
RCS file: nrev.m
diff -N nrev.m
--- /dev/null	Mon Apr 16 11:57:05 2001
+++ nrev.m	Mon Jul 30 23:22:46 2001
@@ -0,0 +1,19 @@
+%---------------------------------------------------------------------------%
+% Copyright (C) 2001 The University of Melbourne.
+% This file may only be copied under the terms of the GNU General
+% Public License - see the file COPYING in the Mercury distribution.
+%---------------------------------------------------------------------------%
+
+:- module nrev.
+
+:- interface.
+:- import_module list. 
+
+:- func nrev(list(T)) = list(T).
+:- mode nrev(in) = out is det.
+
+:- implementation.
+
+nrev([]) = [].
+nrev([X|Xs]) = Ys :- 
+		list__append(nrev(Xs), [X], Ys).
Index: extras/quickcheck/qcheck.m
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/quickcheck/qcheck.m,v
retrieving revision 1.1
diff -u -r1.1 qcheck.m
--- extras/quickcheck/qcheck.m	2001/05/31 02:08:45	1.1
+++ extras/quickcheck/qcheck.m	2001/07/30 13:26:07
@@ -326,8 +326,8 @@
 :- func generate_seed_from_time(time_t) = int.
 :- mode generate_seed_from_time(in) = out.
 generate_seed_from_time(CurrentTime) =  Seed :-
-        tm(Seconds, Minutes, Hours, _Weekday, Yearday, _Month, Year, _DST) 
-	  = time__localtime(CurrentTime),
+        tm(Year, _Month, _MonthDay, Hours, Minutes, Seconds, Yearday, 
+		_Weekday, _DST) = time__localtime(CurrentTime),
 	TotalSecs = ((( integer(Year) * integer(365) + integer(Yearday)) 
 		      * integer(24) + integer(Hours)) 
 		      * integer(60) + integer(Minutes)) 
Index: extras/quickcheck/test_qcheck.m
===================================================================
RCS file: test_qcheck.m
diff -N test_qcheck.m
--- /dev/null	Mon Apr 16 11:57:05 2001
+++ test_qcheck.m	Mon Jul 30 23:23:03 2001
@@ -0,0 +1,35 @@
+%---------------------------------------------------------------------------%
+% Copyright (C) 2001 The University of Melbourne.
+% This file may only be copied under the terms of the GNU General
+% Public License - see the file COPYING in the Mercury distribution.
+%---------------------------------------------------------------------------%
+
+:- module test_qcheck.
+
+:- interface.
+
+:- use_module io.
+
+:- pred main(io__state, io__state).
+:- mode main(di, uo) is det.
+
+%---------------------------------------------------------------------------%
+
+:- implementation.
+
+:- import_module int, list.
+:- import_module qcheck, nrev.
+
+%---------------------------------------------------------------------------%
+
+main -->
+     	qcheck(qcheck__f(testing), "sample testing").
+
+%------------------------------------------------------------------------------%
+% 	Invariant test functions
+%------------------------------------------------------------------------------%
+
+:- func testing(list(int), list(int)) = property.
+testing(Xs, Ys) = 
+	nrev(Xs ++ Ys) `===` (nrev(Ys) ++ nrev(Xs)).
+


-- 
       Tyson Dowd           # 
                            #  Surreal humour isn't everyone's cup of fur.
     trd at cs.mu.oz.au        # 
http://www.cs.mu.oz.au/~trd #
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list