Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pramothragavan committed May 29, 2024
1 parent e01b2aa commit e86bb9a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
25 changes: 16 additions & 9 deletions gap/io.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1399,10 +1399,11 @@ function(config, key)
RemoveCharacters(tempConfig, "Ag$ntd1234567890");

if tempConfig <> "" then
ErrorNoReturn("the format of the file given as the 2nd argument <name> ",
ErrorNoReturn("the format of the file given as the 1st argument <name> ",
"cannot be determined as it contains unexpected ",
"characters: ",
tempConfig);
JoinStringsWithSeparator(tempConfig, ","),
",");
fi;

Pos := PositionProperty(config, x -> x = key[1]);
Expand Down Expand Up @@ -1486,7 +1487,8 @@ function(inputString)
[currentPos + 2 .. Minimum([currentPos + 2,
Length(inputString)])]} = "$"
then
ErrorNoReturn("Syntax error: unexpected characters after \"$$\"");
ErrorNoReturn("Syntax error: unexpected characters",
" (including ':' or '.') after \"$$\"");
else
Add(segments, inputString{[startPos .. currentPos - 1]});
Add(segments, "$$");
Expand Down Expand Up @@ -1593,7 +1595,8 @@ function(graphData, r)
RemoveCharacters(part, ".");
if ForAny(parts{[iter + 1 .. Length(parts)]},
c -> ':' in c) then
ErrorNoReturn("Syntax error: unexpected characters after \".\"",
ErrorNoReturn("Syntax error: unexpected characters (including ':'",
")after \".\"",
"(note that edges cannot be declared after \".\")");
fi;
fi;
Expand All @@ -1604,8 +1607,9 @@ function(graphData, r)

if '$' in part then
if ForAny(part{[iter + 1 .. Length(part)]}, c -> c in ".:") then
ErrorNoReturn("Syntax error: unexpected characters after \"$\"",
"(note that edges cannot be declared after \"$\")");
ErrorNoReturn("Syntax error: unexpected characters (including ':'",
"or '.')after \".\"",
"(note that edges cannot be declared after \".\")");
fi;

if part = "$$" then
Expand Down Expand Up @@ -1704,8 +1708,9 @@ function(name)
file := IO_CompressedFile(UserHomeExpand(name), "r");

if file = fail then
ErrorNoReturn("cannot open the file given as the 1st argument <name>,",
name);
ErrorNoReturn("cannot open the file given as the 1st argument <name>, \"",
name,
"\",");
fi;

config := "";
Expand Down Expand Up @@ -1853,7 +1858,9 @@ function(name, D)

file := IO_CompressedFile(UserHomeExpand(name), "w");
if file = fail then
ErrorNoReturn("cannot open the file given as the 1st argument <name>,");
ErrorNoReturn("cannot open the file given as the 1st argument <name>, \"",
name,
"\",");
fi;

n := DigraphNrVertices(D);
Expand Down
15 changes: 8 additions & 7 deletions tst/standard/io.tst
Original file line number Diff line number Diff line change
Expand Up @@ -927,12 +927,13 @@ gap> ReadDigraphs(filename, IO_Unpickle);
gap> gr := EmptyDigraph(0);;
gap> filename := "does/not/exist.dre";;
gap> WriteDreadnautGraph(filename, gr);
Error, cannot open the file given as the 1st argument <name>,
Error, cannot open the file given as the 1st argument <name>, "does/not/exist.\
dre",
gap> WriteDreadnautGraph(filename, 0);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `WriteDreadnautGraph' on 2 arguments
gap> WriteDreadnautGraph(".", RandomDigraph(2));
Error, cannot open the file given as the 1st argument <name>,
Error, cannot open the file given as the 1st argument <name>, ".",
gap> filename := Concatenation(DIGRAPHS_Dir(), "tst/out/temp.dre");;
gap> D := CompleteDigraph(3);;
gap> WriteDreadnautGraph(filename, D);
Expand All @@ -941,7 +942,7 @@ gap> WriteDreadnautGraph(filename, D);
gap> ReadDreadnautGraph(filename) = D;
true
gap> ReadDreadnautGraph("fakedir.dre");
Error, cannot open the file given as the 1st argument <name>,
Error, cannot open the file given as the 1st argument <name>, "fakedir.dre",
gap> filename := Concatenation(DIGRAPHS_Dir(), "tst/out/bad.dre");;
gap> file := IO_CompressedFile(UserHomeExpand(filename), "w");;
gap> IO_WriteLine(file, "$1n3");;
Expand All @@ -950,7 +951,7 @@ gap> IO_WriteLine(file, "1:1;");;
gap> IO_WriteLine(file, "2:21");;
gap> IO_Close(file);;
gap> ReadDreadnautGraph(filename);
Error, Illegal edge 2 -> 21 (original indexing)
<immutable digraph with 3 vertices, 1 edge>
gap> filename := Concatenation(DIGRAPHS_Dir(), "tst/out/temp.dre");;
gap> D := EmptyDigraph(5);;
gap> WriteDreadnautGraph(filename, D);;
Expand All @@ -976,9 +977,9 @@ gap> IO_WriteLine(file, "n=1dg");;
gap> IO_WriteLine(file, "1: 1.");;
gap> IO_Close(file);;
gap> ReadDreadnautGraph(filename);
Error, the format of the file given as the 2nd argument <name> cannot be deter\
mined,
gap> Exec("rm -f temp.dre");
Error, the format of the file given as the 1st argument <name> cannot be deter\
mined as it contains unexpected characters: 's','i','l','l','y','e','x','f','o\
','r','e','s','i',
# DIGRAPHS_UnbindVariables
gap> Unbind(D);
Expand Down

0 comments on commit e86bb9a

Please sign in to comment.