-
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
607381c
commit e37a9d5
Showing
16 changed files
with
145 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -244,7 +244,7 @@ jobs: | |
- name: Install Dart SDK | ||
run: | | ||
DART_RELEASE_CHANNEL=stable | ||
DART_VERSION=2.12.0 | ||
DART_VERSION=2.13.3 | ||
wget -nv https://storage.googleapis.com/dart-archive/channels/${DART_RELEASE_CHANNEL}/release/${DART_VERSION}/linux_packages/dart_${DART_VERSION}-1_amd64.deb | ||
sudo apt -y install ./dart_${DART_VERSION}-1_amd64.deb | ||
- name: Build and run functional tests | ||
|
@@ -276,8 +276,8 @@ jobs: | |
uses: actions/cache@v2 | ||
with: | ||
path: ~/dart_sdk | ||
key: ${{ runner.os }}-dart-2.12.0-stable | ||
restore-keys: ${{ runner.os }}-dart-2.12.0-stable | ||
key: ${{ runner.os }}-dart-2.13.3-stable | ||
restore-keys: ${{ runner.os }}-dart-2.13.3-stable | ||
- name: Install CMake | ||
uses: jwlawson/[email protected] | ||
with: | ||
|
@@ -289,7 +289,7 @@ jobs: | |
export DART_ROOT=${HOME}/dart_sdk | ||
export DART_BIN=${DART_ROOT}/bin | ||
export PATH=${PATH}:${PWD}/depot_tools:${DART_BIN} | ||
DART_VERSION=2.12.0 | ||
DART_VERSION=2.13.3 | ||
if [ ! -d "${DART_ROOT}/bin" ]; then | ||
sudo apt install -y python2 | ||
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 1 | ||
|
@@ -364,7 +364,7 @@ jobs: | |
- name: Install Dart SDK | ||
run: | | ||
DART_RELEASE_CHANNEL=stable | ||
DART_VERSION=2.12.0 | ||
DART_VERSION=2.13.3 | ||
wget -nv https://storage.googleapis.com/dart-archive/channels/${DART_RELEASE_CHANNEL}/release/${DART_VERSION}/linux_packages/dart_${DART_VERSION}-1_amd64.deb | ||
sudo apt -y install ./dart_${DART_VERSION}-1_amd64.deb | ||
- name: Build and run functional tests | ||
|
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
53 changes: 53 additions & 0 deletions
53
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,53 @@ | ||
// ------------------------------------------------------------------------------------------------- | ||
// 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(PointTypedef(1.0, 3.0)); | ||
|
||
expect(result is Point, 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
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
Oops, something went wrong.