[teyjus] r1170 committed - More tests for open_in, new tests for close_in

2 views
Skip to first unread message

tey...@googlecode.com

unread,
Jan 16, 2015, 6:17:34 PM1/16/15
to teyju...@googlegroups.com
Revision: 1170
Author: fafo...@gmail.com
Date: Fri Jan 16 23:17:15 2015 UTC
Log: More tests for open_in, new tests for close_in

https://code.google.com/p/teyjus/source/detail?r=1170

Added:
/branches/ocaml-builtins/source/test/io_tests/close_in
/branches/ocaml-builtins/source/test/io_tests/close_in/bar
/branches/ocaml-builtins/source/test/io_tests/close_in/close_in.mod
/branches/ocaml-builtins/source/test/io_tests/close_in/close_in.sig
/branches/ocaml-builtins/source/test/io_tests/close_in/close_in.t
Modified:
/branches/ocaml-builtins/source/test/io_tests/open_in/open_in.mod
/branches/ocaml-builtins/source/test/io_tests/open_in/open_in.sig
/branches/ocaml-builtins/source/test/io_tests/open_in/open_in.t

=======================================
--- /dev/null
+++ /branches/ocaml-builtins/source/test/io_tests/close_in/close_in.mod Fri
Jan 16 23:17:15 2015 UTC
@@ -0,0 +1,8 @@
+module close_in.
+
+% Opens and closes a file which exists
+test1 X :- open_in "open_in/bar" X , close_in X.
+% Try to close a file which is already close
+test2 X :- open_in "open_in/bar" X , close_in X, close_in X.
+% Try to close an unbound variable
+test3 :- close_in Unbound.
=======================================
--- /dev/null
+++ /branches/ocaml-builtins/source/test/io_tests/close_in/close_in.sig Fri
Jan 16 23:17:15 2015 UTC
@@ -0,0 +1,5 @@
+sig close_in.
+
+type test1 in_stream -> o.
+type test2 in_stream -> o.
+type test3 o.
=======================================
--- /dev/null
+++ /branches/ocaml-builtins/source/test/io_tests/close_in/close_in.t Fri
Jan 16 23:17:15 2015 UTC
@@ -0,0 +1,49 @@
+use lib '../lib';
+use strict;
+use Test::More tests => 3;
+
+my $TJSIM = "../../tjsim";
+my $PATH = "-p close_in/";
+my $MODULE = "close_in";
+my $code;
+my $ans;
+
+############################################
+############################################
+$code = <<'CODE';
+test1 X.
+CODE
+$ans = <<'ANS';
+
+The answer substitution:
+X = <stream -- "open_in/bar">
+
+ANS
+same_answers( `$TJSIM -b $PATH --solve "$code" $MODULE\n`, $ans,"open_in");
+
+############################################
+# In the following test: we should test that we have the following on
stderr:
+#Error: close_in: Attempting to close an input stream that is already
closed.
+############################################
+$code = <<'CODE';
+test2 X.
+CODE
+$ans = <<'ANS';
+
+The answer substitution:
+ANS
+same_answers( `$TJSIM -b $PATH --solve "$code" $MODULE\n`, $ans,"open_in");
+
+############################################
+# In the following test: we should test that we have the following on
stderr:
+#Error: close_in: Expected stream, found unbound variable.
+############################################
+$code = <<'CODE';
+test3.
+CODE
+$ans = <<'ANS';
+
+The answer substitution:
+ANS
+same_answers( `$TJSIM -b $PATH --solve "$code" $MODULE\n`, $ans,"open_in");
+
=======================================
--- /branches/ocaml-builtins/source/test/io_tests/open_in/open_in.mod Fri
Jan 16 17:31:53 2015 UTC
+++ /branches/ocaml-builtins/source/test/io_tests/open_in/open_in.mod Fri
Jan 16 23:17:15 2015 UTC
@@ -2,3 +2,5 @@

test1 X :- open_in "open_in/foo" X.
test2 X :- open_in "open_in/bar" X.
+test3 X :- open_in "open_in/bar" X ; open_in "open_in/bar" X.
+test4 X :- open_in Unbound X.
=======================================
--- /branches/ocaml-builtins/source/test/io_tests/open_in/open_in.sig Fri
Jan 16 17:31:53 2015 UTC
+++ /branches/ocaml-builtins/source/test/io_tests/open_in/open_in.sig Fri
Jan 16 23:17:15 2015 UTC
@@ -2,3 +2,5 @@

type test1 in_stream -> o.
type test2 in_stream -> o.
+type test3 in_stream -> o.
+type test4 in_stream -> o.
=======================================
--- /branches/ocaml-builtins/source/test/io_tests/open_in/open_in.t Fri Jan
16 17:31:53 2015 UTC
+++ /branches/ocaml-builtins/source/test/io_tests/open_in/open_in.t Fri Jan
16 23:17:15 2015 UTC
@@ -1,6 +1,6 @@
use lib '../lib';
use strict;
-use Test::More tests => 2;
+use Test::More tests => 4;

my $TJSIM = "../../tjsim";
my $PATH = "-p open_in/";
@@ -33,3 +33,30 @@

ANS
same_answers( `$TJSIM -b $PATH --solve "$code" $MODULE\n`, $ans,"open_in");
+
+############################################
+############################################
+$code = <<'CODE';
+test3 X.
+CODE
+$ans = <<'ANS';
+
+The answer substitution:
+X = <stream -- "open_in/bar">
+
+ANS
+same_answers( `$TJSIM -b $PATH --solve "$code" $MODULE\n`, $ans,"open_in");
+
+############################################
+# In the following test: we should test that we have the following on
stderr:
+#Error: open_in: Expected filename, found unbound variable.
+############################################
+$code = <<'CODE';
+test4 X.
+CODE
+$ans = <<'ANS';
+
+The answer substitution:
+ANS
+same_answers( `$TJSIM -b $PATH --solve "$code" $MODULE\n`, $ans,"open_in");
+
Reply all
Reply to author
Forward
0 new messages