Skip to content

Commit

Permalink
Added test for copyClass.
Browse files Browse the repository at this point in the history
  • Loading branch information
perost committed Feb 23, 2016
1 parent aab9e4a commit 691f38d
Show file tree
Hide file tree
Showing 8 changed files with 181 additions and 13 deletions.
138 changes: 138 additions & 0 deletions openmodelica/interactive-API/CopyClass.mos
@@ -0,0 +1,138 @@
// name: CopyClass
// keywords: copyClass
// status: correct
//
// Tests the copyClass API.
//

loadFile("TestFilePkg.mo");
getErrorString();
loadFile("TestDirPkg/package.mo");
getErrorString();

// Top file package to top.
copyClass(TestFilePkg, "TestFilePkgcopy");
getClassInformation(TestFilePkgcopy);

// Top dir package to top.
copyClass(TestDirPkg, "TestDirPkgcopy");
getClassInformation(TestDirPkgcopy);

// Class in top file package to top.
copyClass(TestFilePkg.A, "Acopy");
getClassInformation(Acopy);

// Class in top dir package to top.
copyClass(TestDirPkg.B, "Bcopy");
getClassInformation(Bcopy);

// Package in nested file package to top.
copyClass(TestDirPkg.M1, "M1copy");
getClassInformation(M1copy);

// Package in nested dir package to top.
copyClass(TestDirPkg.SubDirPkg, "SubDirPkgcopy");
getClassInformation(SubDirPkgcopy);

// Class in nested file package to top.
copyClass(TestDirPkg.SubFilePkg.SFPA, "SFPAcopy");
getClassInformation(SFPAcopy);

// Class in nested dir package to top.
copyClass(TestDirPkg.SubDirPkg.SDPA, "SDPAcopy");
getClassInformation(SDPAcopy);

// Top file package to within.
copyClass(TestFilePkg, "TestFilePkgcopy", TestDirPkg);
getClassInformation(TestDirPkg.TestFilePkgcopy);

// Top dir package to within.
copyClass(TestDirPkg, "TestDirPkgcopy", TestDirPkg);
getClassInformation(TestDirPkg.TestDirPkgcopy);

// Class in top file package to within.
copyClass(TestFilePkg.A, "Acopy", TestDirPkg);
getClassInformation(TestDirPkg.Acopy);

// Class in top dir package to within.
copyClass(TestDirPkg.A, "Acopy", TestDirPkg.SubDirPkg);
getClassInformation(TestDirPkg.SubDirPkg.Acopy);

// Nested file package to same scope.
copyClass(TestDirPkg.SubFilePkg, "SubFilePkgcopy", TestDirPkg);
getClassInformation(TestDirPkg.SubFilePkgcopy);

// Nested dir package to same scope.
copyClass(TestDirPkg.SubDirPkg, "SubDirPkgcopy", TestDirPkg);
getClassInformation(TestDirPkg.SubDirPkgcopy);

// Nested file package to different scope.
copyClass(TestDirPkg.SubFilePkg, "SubFilePkgcopy", TestDirPkg.SubDirPkg);
getClassInformation(TestDirPkg.SubDirPkg.SubFilePkgcopy);

// Nested dir package to different scope.
copyClass(TestDirPkg.SubDirPkg, "SubDirPkgcopy", TestDirPkg.SubFilePkg);
getClassInformation(TestDirPkg.SubFilePkg.SubDirPkgcopy);

// Nested class in file package to same scope.
copyClass(TestDirPkg.SubFilePkg.SFPA, "SFPAcopy", TestDirPkg.SubFilePkg);
getClassInformation(TestDirPkg.SubFilePkg.SFPAcopy);

// Nested class in dir package to same scope.
copyClass(TestDirPkg.SubDirPkg.SDPA, "SDPAcopy", TestDirPkg.SubDirPkg);
getClassInformation(TestDirPkg.SubDirPkg.SDPAcopy);

// Nested class in file package to different scope.
copyClass(TestDirPkg.SubFilePkg.SFPA, "SFPAcopy", TestDirPkg.SubDirPkg);
getClassInformation(TestDirPkg.SubDirPkg.SFPAcopy);

// Nested class in dir package to different scope.
copyClass(TestDirPkg.SubDirPkg.SDPA, "SDPAcopy", TestDirPkg.SubFilePkg);
getClassInformation(TestDirPkg.SubFilePkg.SDPAcopy);

// Result:
// true
// ""
// true
// ""
// true
// ("package","",false,false,false,"openmodelica/interactive-API/TestFilePkgcopy.mo",false,1,1,11,16,{},false,false)
// true
// ("package","",false,false,false,"openmodelica/interactive-API/TestDirPkgcopy/package.mo",false,1,1,11,15,{},false,false)
// true
// ("class","",false,false,false,"openmodelica/interactive-API/Acopy.mo",false,8,3,10,8,{},false,false)
// true
// ("class","",false,false,false,"openmodelica/interactive-API/Bcopy.mo",false,7,3,10,8,{},false,false)
// true
// ("model","",false,false,false,"openmodelica/interactive-API/M1copy.mo",false,3,1,6,7,{},false,false)
// true
// ("package","",false,false,false,"openmodelica/interactive-API/SubDirPkgcopy/package.mo",false,3,1,7,14,{},false,false)
// true
// ("class","",false,false,false,"openmodelica/interactive-API/SFPAcopy.mo",false,4,3,6,11,{},false,false)
// true
// ("class","",false,false,false,"openmodelica/interactive-API/SDPAcopy.mo",false,4,3,6,11,{},false,false)
// true
// ("package","",false,false,false,"openmodelica/interactive-API/TestDirPkg/TestFilePkgcopy.mo",false,1,1,11,16,{},false,false)
// true
// ("package","",false,false,false,"openmodelica/interactive-API/TestDirPkg/TestDirPkgcopy/package.mo",false,1,1,11,15,{},false,false)
// true
// ("class","",false,false,false,"openmodelica/interactive-API/TestDirPkg/Acopy.mo",false,8,3,10,8,{},false,false)
// true
// ("class","",false,false,false,"openmodelica/interactive-API/TestDirPkg/SubDirPkg/Acopy.mo",false,2,3,5,8,{},false,false)
// true
// ("package","",false,false,false,"openmodelica/interactive-API/TestDirPkg/SubFilePkgcopy.mo",false,3,1,7,15,{},false,false)
// true
// ("package","",false,false,false,"openmodelica/interactive-API/TestDirPkg/SubDirPkgcopy/package.mo",false,3,1,7,14,{},false,false)
// true
// ("package","",false,false,false,"openmodelica/interactive-API/TestDirPkg/SubDirPkg/SubFilePkgcopy.mo",false,3,1,7,15,{},false,false)
// true
// ("package","",false,false,false,"openmodelica/interactive-API/TestDirPkg/SubFilePkg/SubDirPkgcopy/package.mo",false,3,1,7,14,{},false,false)
// true
// ("class","",false,false,false,"openmodelica/interactive-API/TestDirPkg/SubFilePkg.mo",false,4,3,6,11,{},false,false)
// true
// ("class","",false,false,false,"openmodelica/interactive-API/TestDirPkg/SubDirPkg/package.mo",false,4,3,6,11,{},false,false)
// true
// ("class","",false,false,false,"openmodelica/interactive-API/TestDirPkg/SubDirPkg/SFPAcopy.mo",false,4,3,6,11,{},false,false)
// true
// ("class","",false,false,false,"openmodelica/interactive-API/TestDirPkg/SubFilePkg/SDPAcopy.mo",false,4,3,6,11,{},false,false)
// endResult
1 change: 1 addition & 0 deletions openmodelica/interactive-API/Makefile
Expand Up @@ -11,6 +11,7 @@ Bug3282.mos \
Bug3417.mos \
Bug3520.mos \
ConvertUnits.mos \
CopyClass.mos \
choicesAllMatching.mos \
DefaultComponentName.mos \
DeleteConnection.mos \
Expand Down
6 changes: 6 additions & 0 deletions openmodelica/interactive-API/TestDirPkg/M1.mo
@@ -0,0 +1,6 @@
within TestDirPkg;

model M1
model MM1
end MM1;
end M1;
7 changes: 7 additions & 0 deletions openmodelica/interactive-API/TestDirPkg/SubDirPkg/package.mo
@@ -0,0 +1,7 @@
within TestDirPkg;

package SubDirPkg
class SDPA
class SSDPA end SSDPA;
end SDPA;
end SubDirPkg;
7 changes: 7 additions & 0 deletions openmodelica/interactive-API/TestDirPkg/SubFilePkg.mo
@@ -0,0 +1,7 @@
within TestDirPkg;

package SubFilePkg
class SFPA
class SSFPA end SSFPA;
end SFPA;
end SubFilePkg;
11 changes: 11 additions & 0 deletions openmodelica/interactive-API/TestDirPkg/package.mo
@@ -0,0 +1,11 @@
package TestDirPkg
class A
class AA
end AA;
end A;

class B
class BB
end BB;
end B;
end TestDirPkg;
11 changes: 11 additions & 0 deletions openmodelica/interactive-API/TestFilePkg.mo
@@ -0,0 +1,11 @@
package TestFilePkg
package SubPkg
class SA
class SSA end SSA;
end SA;
end SubPkg;

class A
class AA end AA;
end A;
end TestFilePkg;
13 changes: 0 additions & 13 deletions openmodelica/interactive-API/interactive_api_classes.mos
Expand Up @@ -42,11 +42,6 @@ addConnection(a.n,b.z,A.test);
addConnection(a.n[1],b.z[2],A.test);
getNthConnection(A.test,1);
getClassNames(A);
copyClass(A, "B");
getClassNames();
copyClass(A, "B", test2);
getClassNames(test2);


clear();

Expand Down Expand Up @@ -163,14 +158,6 @@ getClassNames(A);
// {a.n[1],b.z[2], ""}
// Evaluating: getClassNames(A)
// {test}
// Evaluating: copyClass(A, "B")
// true
// Evaluating: getClassNames()
// {B,test2,A}
// Evaluating: copyClass(A, "B", test2)
// true
// Evaluating: getClassNames(test2)
// {B}
// Evaluating: clear()
// true
// Evaluating: getAnnotationVersion()
Expand Down

0 comments on commit 691f38d

Please sign in to comment.