[m-rev.] diff: various minor fixes
Peter Wang
novalazy at gmail.com
Mon Mar 28 10:18:21 AEDT 2011
Branches: main, 11.01
Minor fixes.
library/io.m:
Add `may_not_duplicate' to some Erlang foreign_procs.
tests/general/test_string_to_int_overflow.exp:
tests/general/test_string_to_int_overflow.exp2:
tests/general/test_string_to_int_overflow.exp3:
tests/general/test_string_to_int_overflow.m:
Make this test case work with arbitrary-precision integers, namely with
the Erlang backend.
tests/hard_coded/trace_goal_4.m:
Fix a format specifier in Erlang foreign_proc.
tests/hard_coded/expand.exp2:
tests/hard_coded/write.exp2:
tests/hard_coded/write_reg1.exp2:
Delete leading zeros in exponents, not produced in any current grade.
tests/hard_coded/write.exp3:
Add expected output for csharp grade.
diff --git a/library/io.m b/library/io.m
index 89d0d94..57386ad 100644
--- a/library/io.m
+++ b/library/io.m
@@ -3189,7 +3189,8 @@ file_type_implemented :-
:- pragma foreign_proc("Erlang",
io.file_type_2(FollowSymLinks::in, FileName::in,
Result::out, _IO0::di, _IO::uo),
- [may_call_mercury, promise_pure, tabled_for_io, thread_safe, terminates],
+ [may_call_mercury, promise_pure, tabled_for_io, thread_safe, terminates,
+ may_not_duplicate],
"
FileNameStr = binary_to_list(FileName),
case FollowSymLinks of
@@ -3452,7 +3453,7 @@ io.check_file_accessibility(FileName, AccessTypes, Result, !IO) :-
io.check_file_accessibility_2(FileName::in, AccessTypes::in, Result::out,
_IO0::di, _IO::uo),
[may_call_mercury, promise_pure, tabled_for_io, thread_safe, terminates,
- does_not_affect_liveness],
+ does_not_affect_liveness, may_not_duplicate],
"
FileNameStr = binary_to_list(FileName),
case file:read_file_info(FileNameStr) of
@@ -3972,7 +3973,8 @@ io.file_id(FileName, Result, !IO) :-
:- pragma foreign_proc("Erlang",
io.file_id_2(FileName::in, Status::out, Msg::out,
FileId::out, _IO0::di, _IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
+ [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe,
+ may_not_duplicate],
"
FileNameStr = binary_to_list(FileName),
case file:read_file_info(FileNameStr) of
diff --git a/tests/general/test_string_to_int_overflow.exp b/tests/general/test_string_to_int_overflow.exp
index 66f6f61..765d20a 100644
--- a/tests/general/test_string_to_int_overflow.exp
+++ b/tests/general/test_string_to_int_overflow.exp
@@ -1 +1 @@
-[yes, no, yes, yes]
+[yes(999), no, yes(-1), yes(999)]
diff --git a/tests/general/test_string_to_int_overflow.exp2 b/tests/general/test_string_to_int_overflow.exp2
new file mode 100644
index 0000000..d7616f0
--- /dev/null
+++ b/tests/general/test_string_to_int_overflow.exp2
@@ -0,0 +1 @@
+[yes(999), yes(99999999999999999999), yes(1099511627775), yes(999)]
diff --git a/tests/general/test_string_to_int_overflow.exp3 b/tests/general/test_string_to_int_overflow.exp3
new file mode 100644
index 0000000..c8e6e1d
--- /dev/null
+++ b/tests/general/test_string_to_int_overflow.exp3
@@ -0,0 +1 @@
+[yes(999), no, yes(1099511627775), yes(999)]
diff --git a/tests/general/test_string_to_int_overflow.m b/tests/general/test_string_to_int_overflow.m
index 9d4a14b..120d56f 100644
--- a/tests/general/test_string_to_int_overflow.m
+++ b/tests/general/test_string_to_int_overflow.m
@@ -21,18 +21,18 @@
:- implementation.
-:- import_module bool.
:- import_module list.
+:- import_module maybe.
:- import_module string.
%-----------------------------------------------------------------------------%
main(!IO) :-
Xs = [
- ( if string.to_int("999", _) then yes else no ),
- ( if string.to_int("99999999999999999999", _) then yes else no ),
- ( if string.base_string_to_int(16, "ffffffffff", _) then yes else no ),
- ( if string.base_string_to_int(10, "999", _) then yes else no )
+ ( if string.to_int("999", I0) then yes(I0) else no),
+ ( if string.to_int("99999999999999999999", I1) then yes(I1) else no ),
+ ( if base_string_to_int(16, "ffffffffff", I2) then yes(I2) else no ),
+ ( if base_string_to_int(10, "999", I3) then yes(I3) else no )
],
io.print(Xs, !IO),
io.nl(!IO).
diff --git a/tests/hard_coded/expand.exp2 b/tests/hard_coded/expand.exp2
index bdc3a8e..40d1679 100644
--- a/tests/hard_coded/expand.exp2
+++ b/tests/hard_coded/expand.exp2
@@ -125,16 +125,16 @@ no arguments
expand: functor 3.14159000000000 arity 0 arguments []
deconstruct_du failed
-1.12832498300000e-021/0
+1.12832498300000e-21/0
functor_number_cc failed
no arguments
-expand: functor 1.12832498300000e-021 arity 0 arguments []
+expand: functor 1.12832498300000e-21 arity 0 arguments []
deconstruct_du failed
-2.23954899000000e+023/0
+2.23954899000000e+23/0
functor_number_cc failed
no arguments
-expand: functor 2.23954899000000e+023 arity 0 arguments []
+expand: functor 2.23954899000000e+23 arity 0 arguments []
deconstruct_du failed
-65/0
diff --git a/tests/hard_coded/trace_goal_4.m b/tests/hard_coded/trace_goal_4.m
index 106c774..186f744 100644
--- a/tests/hard_coded/trace_goal_4.m
+++ b/tests/hard_coded/trace_goal_4.m
@@ -47,6 +47,6 @@ main(!IO) :-
progress_report(X::in),
[will_not_call_mercury, thread_safe, tabled_for_io],
"
- io:format(""Progress reported ~a~n"", [X])
+ io:format(""Progress reported ~p~n"", [X])
").
diff --git a/tests/hard_coded/write.exp2 b/tests/hard_coded/write.exp2
index afdc1fc..5e50c45 100644
--- a/tests/hard_coded/write.exp2
+++ b/tests/hard_coded/write.exp2
@@ -31,8 +31,8 @@ TESTING BUILTINS
'a'
'&'
3.14159000000000
-1.12832498300000e-021
-2.23954899000000e+023
+1.12832498300000e-21
+2.23954899000000e+23
-65
4
univ_cons(["hi! I\'m a univ!"])
diff --git a/tests/hard_coded/write.exp3 b/tests/hard_coded/write.exp3
new file mode 100644
index 0000000..8f0fa6b
--- /dev/null
+++ b/tests/hard_coded/write.exp3
@@ -0,0 +1,48 @@
+var("X") + int(3) * var("X^2") ; (type)
+{ type }
+{ ':-' }
+':-'
+{ blah }
+blah ; (type), (type) * blah ; (type)
+((blah ; blah), blah) * blah ; blah
+(type) * blah ; (type)
+TESTING DISCRIMINATED UNIONS
+one
+two
+three
+apple([9, 5, 1])
+banana([three, one, two])
+zop(3.3, 2.03)
+zip(3, 2)
+zap(3, -2.111)
+wombat
+foo
+
+TESTING POLYMORPHISM
+poly_one([2399.3])
+poly_two(3)
+poly_three(3.33, 4, poly_one(9.11))
+
+TESTING BUILTINS
+""
+"Hello, world\n"
+"Foo%sFoo"
+"\""
+'a'
+'&'
+3.14159
+1.128324983E-21
+2.23954899E+23
+-65
+4
+univ_cons(["hi! I\'m a univ!"])
+'<<predicate>>'
+
+TESTING OTHER TYPES
+var(1)
+var_supply(0)
+var_supply(1)
+empty
+qwerty(4)
+array([1, 2, 3, 4])
+
diff --git a/tests/hard_coded/write_reg1.exp2 b/tests/hard_coded/write_reg1.exp2
index 6388323..e335b7a 100644
--- a/tests/hard_coded/write_reg1.exp2
+++ b/tests/hard_coded/write_reg1.exp2
@@ -23,12 +23,13 @@ TESTING BUILTINS
'a'
'&'
3.14159000000000
-1.12832498300000e-021
-2.23954899000000e+023
+1.12832498300000e-21
+2.23954899000000e+23
-65
4
univ_cons(["hi! I\'m a univ!"])
'<<predicate>>'
+'<<predicate>>'
TESTING OTHER TYPES
var(1)
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list