Skip to content

Commit e6275f1

Browse files
author
gossen
committed
Add flattening test case for external object located in extended class
1 parent 90699f2 commit e6275f1

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ gitlibraries.log
8383
# Sorted by time it takes to run the tests...
8484
# DO NOT ADD ANYTHING HERE THAT YOU EXPECT WILL TAKE MORE THAN 5 SECONDS TO RUN IN THE NEXT 18 YEARS
8585
FASTLOGS= \
86+
modelicaexternal-objects.log \
8687
simulationalgorithms-functions.log \
8788
simulationarrays.log \
8889
simulationasserts.log \
@@ -208,6 +209,9 @@ modelicaothers.log: omc-diff
208209
modelicaexternal-functions.log: omc-diff
209210
$(MAKE) -C flattening/modelica/external-functions -f Makefile test > $@
210211
@echo $@ done
212+
modelicaexternal-objects.log: omc-diff
213+
$(MAKE) -C flattening/modelica/external-objects -f Makefile test > $@
214+
@echo $@ done
211215
modelicaequations.log: omc-diff
212216
$(MAKE) -C flattening/modelica/equations -f Makefile test > $@
213217
@echo $@ done
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# relative path to rtest
2+
TEST = ../../../rtest -v
3+
4+
# Tests to run.
5+
TESTFILES = testExternalObject.mo
6+
7+
# test that currently fail. Move up when fixed.
8+
FAILINGTESTFILES= \
9+
10+
# Dependency files that are not .mo .mos or Makefile
11+
# Add them here or they will be cleaned.
12+
DEPENDENCIES = \
13+
*.mo \
14+
*.mos \
15+
Makefile
16+
17+
CLEAN = `ls | grep -w -v -f deps.tmp`
18+
19+
.PHONY : test clean getdeps
20+
21+
test :
22+
@echo
23+
@echo Running tests...
24+
@echo
25+
@echo OPENMODELICAHOME=" $(OPENMODELICAHOME) "
26+
@$(TEST) $(TESTFILES)
27+
28+
# Cleans all files that are not listed as dependencies
29+
clean :
30+
@echo $(DEPENDENCIES) | sed 's/ /\\|/g' > deps.tmp
31+
@rm -f $(CLEAN)
32+
33+
# Run this if you want to list out the files (dependencies).
34+
# do it after cleaning and updating the folder
35+
# then you can get a list of file names (which must be dependencies
36+
# since you got them from repository + your own new files)
37+
# then add them to the DEPENDENCIES. You can find the
38+
# list in deps.txt
39+
getdeps:
40+
@echo $(DEPENDENCIES) | sed 's/ /\\|/g' > deps.tmp
41+
@echo $(CLEAN) | sed -r 's/deps.txt|deps.tmp//g' | sed 's/ / \\\n/g' > deps.txt
42+
@echo Dependency list saved in deps.txt.
43+
@echo Copy the list from deps.txt and add it to the Makefile @DEPENDENCIES
44+
45+
failingtest :
46+
@echo
47+
@echo Running failing tests...
48+
@echo
49+
@$(TEST) $(FAILINGTESTFILES)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// name: testExternalObject
2+
// keywords: external object
3+
// cflags: +i=ExtObjectTest.Ex
4+
// status: correct
5+
//
6+
// description: External object in extended class
7+
8+
package ExtObjectTest
9+
model Ex
10+
package ExtPackage1 = ExtPackage;
11+
ExtPackage1.ExtObj mapping = ExtPackage1.ExtObj();
12+
end Ex;
13+
14+
package ExtPackage
15+
class ExtObj
16+
extends ExternalObject;
17+
function constructor
18+
output ExtObj mapping;
19+
external "C" mapping = initMapping();
20+
end constructor;
21+
function destructor
22+
input ExtObj mapping;
23+
external "C" destroyMapping(mapping);
24+
end destructor;
25+
end ExtObj;
26+
end ExtPackage;
27+
end ExtObjectTest;
28+
29+
// Result:
30+
// function ExtObjectTest.Ex.ExtPackage1.ExtObj.constructor
31+
// output ExtObjectTest.Ex.ExtPackage1.ExtObj mapping;
32+
//
33+
// external "C" mapping = initMapping();
34+
// end ExtObjectTest.Ex.ExtPackage1.ExtObj.constructor;
35+
//
36+
// function ExtObjectTest.Ex.ExtPackage1.ExtObj.destructor
37+
// input ExtObjectTest.Ex.ExtPackage1.ExtObj mapping;
38+
//
39+
// external "C" destroyMapping(mapping);
40+
// end ExtObjectTest.Ex.ExtPackage1.ExtObj.destructor;
41+
//
42+
// class ExtObjectTest.Ex
43+
// ExtObjectTest.Ex.ExtPackage1.ExtObj mapping = ExtObjectTest.Ex.ExtPackage1.ExtObj.constructor();
44+
// end ExtObjectTest.Ex;

0 commit comments

Comments
 (0)