Changeset 180:ca80a1c7f2ed
- Timestamp:
- 04/24/2012 10:05:33 PM (13 months ago)
- Author:
- Andreas Schaefer <gentryx@…>
- Branch:
- default
- Message:
-
fixed TypemapGenerator?'s unit tests
- Location:
- tools/typemapgenerator
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r179
|
r180
|
|
| 58 | 58 | end |
| 59 | 59 | member_specs = member_specs1 + member_specs2 |
| 60 | | ret.sub!(/ *MEMBERSPECS/, member_specs.join(",\n")) |
| | 60 | ret.sub!(/ *MEMBERSPECS/, member_specs.sort.join(",\n")) |
| 61 | 61 | end |
| 62 | 62 | |
-
|
r92
|
r180
|
|
| 64 | 64 | # it'll try to create a new MPI type map specification. |
| 65 | 65 | def resolve_forest(classes) |
| 66 | | classes = classes.dup |
| | 66 | classes = classes.sort |
| 67 | 67 | resolved_classes = { } |
| 68 | 68 | resolved_parents = { } |
| … |
… |
|
| 128 | 128 | end |
| 129 | 129 | |
| 130 | | return params.uniq |
| | 130 | return params.sort.uniq |
| 131 | 131 | end |
| 132 | 132 | |
-
|
r0
|
r180
|
|
| 9 | 9 | // sort addresses in ascending order |
| 10 | 10 | MemberSpec rawSpecs[] = { |
| | 11 | MemberSpec(MPI::Get_address(&obj->capacity), MPI::DOUBLE, 1), |
| 11 | 12 | MemberSpec(MPI::Get_address(&obj->fuel), MPI::INT, 1), |
| 12 | | MemberSpec(MPI::Get_address(&obj->gearRatios), MPI::DOUBLE, 6), |
| 13 | | MemberSpec(MPI::Get_address(&obj->capacity), MPI::DOUBLE, 1) |
| | 13 | MemberSpec(MPI::Get_address(&obj->gearRatios), MPI::DOUBLE, 6) |
| 14 | 14 | }; |
| 15 | 15 | std::sort(rawSpecs, rawSpecs + count, addressLower); |
-
|
r0
|
r180
|
|
| 3 | 3 | |
| 4 | 4 | namespace MPI \{ |
| | 5 | Datatype RIM; |
| 5 | 6 | Datatype TIRE; |
| 6 | | Datatype RIM; |
| 7 | 7 | Datatype WHEEL; |
| 8 | 8 | \} |
| … |
… |
|
| 28 | 28 | |
| 29 | 29 | MPI\:\:Datatype |
| 30 | | Typemaps\:\:generateMapTire\(\) \{.* |
| | 30 | Typemaps\:\:generateMapRim\(\) \{.* |
| 31 | 31 | \} |
| 32 | 32 | |
| 33 | 33 | MPI\:\:Datatype |
| 34 | | Typemaps\:\:generateMapRim\(\) \{.* |
| | 34 | Typemaps\:\:generateMapTire\(\) \{.* |
| 35 | 35 | \} |
| 36 | 36 | |
| … |
… |
|
| 41 | 41 | void Typemaps\:\:initializeMaps\(\) |
| 42 | 42 | \{ |
| | 43 | MPI\:\:RIM = generateMapRim\(\); |
| 43 | 44 | MPI\:\:TIRE = generateMapTire\(\); |
| 44 | | MPI\:\:RIM = generateMapRim\(\); |
| 45 | 45 | MPI\:\:WHEEL = generateMapWheel\(\); |
| 46 | 46 | \} |
-
|
r0
|
r180
|
|
| 4 | 4 | #include <complex> |
| 5 | 5 | #include <mpi.h> |
| 6 | | #include "/home/gentryx/typemapgenerator/trunk/test/fixtures/src/tire.h" |
| 7 | | #include "/home/gentryx/typemapgenerator/trunk/test/fixtures/src/rim.h" |
| 8 | | #include "/home/gentryx/typemapgenerator/trunk/test/fixtures/src/wheel.h" |
| | 6 | #include <rim.h> |
| | 7 | #include <tire.h> |
| | 8 | #include <wheel.h> |
| 9 | 9 | |
| 10 | 10 | namespace MPI { |
| | 11 | extern Datatype RIM; |
| 11 | 12 | extern Datatype TIRE; |
| 12 | | extern Datatype RIM; |
| 13 | 13 | extern Datatype WHEEL; |
| 14 | 14 | } |
| … |
… |
|
| 24 | 24 | |
| 25 | 25 | private: |
| | 26 | static MPI::Datatype generateMapRim(); |
| 26 | 27 | static MPI::Datatype generateMapTire(); |
| 27 | | static MPI::Datatype generateMapRim(); |
| 28 | 28 | static MPI::Datatype generateMapWheel(); |
| 29 | 29 | |
| … |
… |
|
| 47 | 47 | static inline MPI::Datatype lookup(unsigned short*) { return MPI::UNSIGNED_SHORT; } |
| 48 | 48 | static inline MPI::Datatype lookup(wchar_t*) { return MPI::WCHAR; } |
| | 49 | static inline MPI::Datatype lookup(Rim*) { return MPI::RIM; } |
| 49 | 50 | static inline MPI::Datatype lookup(Tire*) { return MPI::TIRE; } |
| 50 | | static inline MPI::Datatype lookup(Rim*) { return MPI::RIM; } |
| 51 | 51 | static inline MPI::Datatype lookup(Wheel*) { return MPI::WHEEL; } |
| 52 | 52 | }; |
-
|
r0
|
r180
|
|
| 46 | 46 | @headers) |
| 47 | 47 | # avoid comparing absolute pathnames (beneficial as the tests have to run in various locations) |
| 48 | | expected_header.gsub!(/(#include ").*\/(\w+\.h")/) { |m| $1+$2 } |
| 49 | | actual_header.gsub!( /(#include ").*\/(\w+\.h")/) { |m| $1+$2 } |
| | 48 | expected_header.gsub!(/(#include <).*\/(\w+\.h>)/) { |m| $1+$2 } |
| | 49 | actual_header.gsub!( /(#include <).*\/(\w+\.h>)/) { |m| $1+$2 } |
| | 50 | |
| 50 | 51 | assert_equal(expected_header, actual_header) |
| 51 | 52 | end |
-
|
r0
|
r180
|
|
| 146 | 146 | |
| 147 | 147 | def test_used_template_parameters |
| 148 | | expected = [["int", "int"], ["int", "double"], |
| 149 | | ["Coord<3 >", "Coord<2 >"]] |
| | 148 | expected = [["Coord<3 >", "Coord<2 >"], |
| | 149 | ["int", "double"], |
| | 150 | ["int", "int"]] |
| 150 | 151 | assert_equal(expected, @parser.used_template_parameters("CoordPair")) |
| 151 | 152 | |
| … |
… |
|
| 367 | 368 | } |
| 368 | 369 | |
| 369 | | expected_sortation = %w{Rim Engine Tire Wheel Car} |
| | 370 | expected_sortation = %w{Engine Tire Rim Wheel Car} |
| 370 | 371 | |
| 371 | 372 | expected_headers = |
| 372 | | ["fixtures/src/rim.h", |
| 373 | | "fixtures/src/engine.h", |
| | 373 | ["fixtures/src/engine.h", |
| 374 | 374 | "fixtures/src/tire.h", |
| | 375 | "fixtures/src/rim.h", |
| 375 | 376 | "fixtures/src/wheel.h", |
| 376 | 377 | "fixtures/src/car.h"] |
| … |
… |
|
| 426 | 427 | resolved_classes = @parser.resolve_forest(classes)[0] |
| 427 | 428 | |
| 428 | | |
| 429 | | assert_equal(%w(wheels), |
| 430 | | resolved_classes["Car"].keys) |
| 431 | | assert_equal(%w(size spareWheel), resolved_classes["CarContainer"].keys) |
| | 429 | assert_equal(%w(wheels), resolved_classes["Car"].keys) |
| | 430 | assert_equal(%w(size spareWheel), resolved_classes["CarContainer"].keys.sort) |
| 432 | 431 | end |
| 433 | 432 | |