Skip to content

Commit

Permalink
Add test for #3424
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund committed Sep 3, 2015
1 parent cbdd59d commit 8f12f4a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
7 changes: 6 additions & 1 deletion openmodelica/bootstrapping/TestDiffAlgorithm.mo
Expand Up @@ -3,6 +3,11 @@ function id<T>
output T o=i;
end id;

function isWhitespace<T>
input T t;
output Boolean b = false;
end isWhitespace;

function TestDiffAlgorithm
protected
list<tuple<DiffAlgorithm.Diff, list<Integer>>> intDiffs;
Expand Down Expand Up @@ -49,5 +54,5 @@ algorithm
print(" seq1={" + stringDelimitList(list(toString(e) for e in seq1), ", ") + "},\n");
print(" seq2={" + stringDelimitList(list(toString(e) for e in seq2), ", ") + "}\n");
print(")\n");
out := DiffAlgorithm.diff(seq1, seq2, equals);
out := DiffAlgorithm.diff(seq1, seq2, equals, isWhitespace, toString);
end debug_diff;
36 changes: 36 additions & 0 deletions openmodelica/diff/AddComponent2.mos
@@ -0,0 +1,36 @@
// status: correct

echo(false);
s1 := "model M1
annotation(Icon(coordinateSystem(
preserveAspectRatio=false,
extent={{-100,-100},{100,100}}), graphics={
Line(points={{-60,50},{60,50}}, color={0,0,255}),
Line(points={{-40,30},{40,30}}, color={0,0,255}),
Line(points={{-20,10},{20,10}}, color={0,0,255}),
Line(points={{0,90},{0,50}}, color={0,0,255})}));
end M1;";
loadString(s1, "M1.mo");
getErrorString();
addComponent(m1, Real, M1, annotate=Placement(visible=true, transformation=transformation(origin={-24,-54}, extent={{-10,-10},{10,10}}, rotation=0)));
getErrorString();
answer := "model M1
Real m1 annotation(Placement(visible = true, transformation(origin = {-24, -54}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
annotation(Icon(coordinateSystem(
preserveAspectRatio=false,
extent={{-100,-100},{100,100}}), graphics={
Line(points={{-60,50},{60,50}}, color={0,0,255}),
Line(points={{-40,30},{40,30}}, color={0,0,255}),
Line(points={{-20,10},{20,10}}, color={0,0,255}),
Line(points={{0,90},{0,50}}, color={0,0,255})}));
end M1;";
s2 := listFile(M1);
//print(s2);
res := diffModelicaFileListings(s1, s2, OpenModelica.Scripting.DiffFormat.plain);
if answer<>res then
print("\nFailed \n");
exit(1);
end if;

// Result:
// endResult
1 change: 1 addition & 0 deletions openmodelica/diff/Makefile
Expand Up @@ -3,6 +3,7 @@ TEST = ../../rtest

TESTFILES = \
AddComponent.mos \
AddComponent2.mos \
ChangeSourceFile.mos \
TestDiffListAPI.mos

Expand Down

0 comments on commit 8f12f4a

Please sign in to comment.