mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-23 21:33:49 +00:00
Estimated hours taken: 1 runtests: Compare actual outputs with the outputs computed by NU-Prolog. Mmake: Enable the dnf test. commit_bug.m: Use more readable formatting. environment.m: Since the expected output may be generated on a different machine than the one on which the test is run, don't print the value of a possibly machine-specific environment variable such as PATH. semidet_lambda.m: Fix the name of the module. univ.m: Add a couple of tests to exercise the typeinfo comparison routine. unreachable.m: Fix a comment. *.exp: The expected output files.
51 lines
1.3 KiB
Mathematica
51 lines
1.3 KiB
Mathematica
% Short series of tests for io__get_environment_var and
|
|
% io__set_environment_var.
|
|
%
|
|
% Author: bromage
|
|
|
|
:- module environment.
|
|
|
|
:- interface.
|
|
:- import_module io.
|
|
:- pred main(io__state :: di, io__state :: uo) is det.
|
|
|
|
:- implementation.
|
|
:- import_module list, bool, std_util, string.
|
|
|
|
:- pred environment__test(string, bool, bool, io__state, io__state).
|
|
:- mode environment__test(in, in, in, di, uo) is det.
|
|
environment__test(Var, ShouldBeSet, ShouldBePrinted) -->
|
|
io__get_environment_var(Var, MaybeValue),
|
|
io__write_strings(["Variable \"", Var, "\" is set "]),
|
|
( { MaybeValue = yes(Value) } ->
|
|
( { ShouldBePrinted = yes } ->
|
|
io__write_strings(["to \"", Value, "\" "])
|
|
;
|
|
[]
|
|
),
|
|
{ Ok = ShouldBeSet }
|
|
;
|
|
io__write_string("not set "),
|
|
{ bool__not(ShouldBeSet, Ok) }
|
|
),
|
|
( { Ok = yes } ->
|
|
io__write_string("(passed)\n")
|
|
;
|
|
io__write_string("(failed)\n")
|
|
).
|
|
|
|
main -->
|
|
% PATH should be set on all Unix systems but may differ
|
|
% on the different machines that generate .exp and .out files
|
|
environment__test("PATH", yes, no),
|
|
|
|
% This one probably isn't. :-)
|
|
environment__test("SHOULD_NOT_BE_SET", no, yes),
|
|
|
|
% So set it...
|
|
io__set_environment_var("SHOULD_NOT_BE_SET", "Hello World!"),
|
|
|
|
% Did that work?
|
|
environment__test("SHOULD_NOT_BE_SET", yes, yes).
|
|
|