-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added dedicated DartTypeAlias template, as type aliases (typedefs) are now supported in Dart language (since Dart version 2.13). Updated other Dart tempates and resolvers to treat type aliases as a normal type, instead of skipping it through to the target type. Added/updated related smoke and functional tests. Unrelated smoke tests are updated in a separate commit. Resolves: #907 Signed-off-by: Daniel Kamkha <[email protected]>
- Loading branch information
1 parent
861ba70
commit bd7f7e1
Showing
16 changed files
with
139 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
functional-tests/functional/dart/test/TypeAliases_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// ------------------------------------------------------------------------------------------------- | ||
// Copyright (C) 2016-2021 HERE Europe B.V. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// License-Filename: LICENSE | ||
// | ||
// ------------------------------------------------------------------------------------------------- | ||
|
||
import "package:test/test.dart"; | ||
import "package:functional/test.dart"; | ||
import "../test_suite.dart"; | ||
|
||
final _testSuite = TestSuite("Type Aliases"); | ||
|
||
void main() { | ||
_testSuite.test("Type alias to struct", () { | ||
final result = StaticTypedefExampleStructTypedef("nonsense"); | ||
|
||
expect(result is StaticTypedefExampleStruct, isTrue); | ||
expect(result.exampleString, "nonsense"); | ||
}); | ||
_testSuite.test("Type alias used by a function", () { | ||
final result = StaticTypedef.returnIntTypedef(2); | ||
|
||
expect(result is int, isTrue); | ||
expect(result, 3); | ||
}); | ||
_testSuite.test("Type alias points to a type alias", () { | ||
final result = StaticTypedef.returnNestedIntTypedef(4); | ||
|
||
expect(result is int, isTrue); | ||
expect(result, 5); | ||
}); | ||
_testSuite.test("Type alias from type collection", () { | ||
final result = StaticTypedef.returnTypedefPointFromTypeCollection( | ||
TypeCollectionPointTypedef(1.0, 3.0) | ||
); | ||
|
||
expect(result is TypeCollectionPoint, isTrue); | ||
expect(result.x, 1.0); | ||
expect(result.y, 3.0); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
gluecodium/src/main/resources/templates/dart/DartTypeAlias.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{{!! | ||
! | ||
! Copyright (C) 2016-2021 HERE Europe B.V. | ||
! | ||
! Licensed under the Apache License, Version 2.0 (the "License"); | ||
! you may not use this file except in compliance with the License. | ||
! You may obtain a copy of the License at | ||
! | ||
! http://www.apache.org/licenses/LICENSE-2.0 | ||
! | ||
! Unless required by applicable law or agreed to in writing, software | ||
! distributed under the License is distributed on an "AS IS" BASIS, | ||
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
! See the License for the specific language governing permissions and | ||
! limitations under the License. | ||
! | ||
! SPDX-License-Identifier: Apache-2.0 | ||
! License-Filename: LICENSE | ||
! | ||
!}} | ||
{{>dart/DartDocumentation}}{{>dart/DartAttributes}} | ||
typedef {{resolveName visibility}}{{resolveName}} = {{resolveName typeRef}}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters