Skip to content

Commit 90a78fd

Browse files
authored
Add more data asset test projects (#1287)
--- <details> <summary>Contribution guidelines:</summary><br> - See our [contributor guide](https://github.com/dart-lang/.github/blob/main/CONTRIBUTING.md) for general expectations for PRs. - Larger or significant changes should be discussed in an issue before creating a PR. - Contributions to our repos should follow the [Dart style guide](https://dart.dev/guides/language/effective-dart) and use `dart format`. - Most changes should add an entry to the changelog and may need to [rev the pubspec package version](https://github.com/dart-lang/sdk/blob/main/docs/External-Package-Maintenance.md#making-a-change). - Changes to packages require [corresponding tests](https://github.com/dart-lang/.github/blob/main/CONTRIBUTING.md#Testing). Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback. </details>
1 parent d7a4f19 commit 90a78fd

File tree

6 files changed

+42
-2
lines changed

6 files changed

+42
-2
lines changed

pkgs/native_assets_builder/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.8.1-wip
2+
3+
- Add more data asset test files.
4+
15
## 0.8.0
26

37
- `BuildRunner.build` and `BuildRunner.buildDryRun` now have a required

pkgs/native_assets_builder/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: native_assets_builder
22
description: >-
33
This package is the backend that invokes build hooks.
4-
version: 0.8.0
4+
version: 0.8.1-wip
55
repository: https://github.com/dart-lang/native/tree/main/pkgs/native_assets_builder
66

77
# publish_to: none

pkgs/native_assets_builder/test_data/manifest.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@
8989
- simple_data_asset/README.md
9090
- simple_data_asset/hook/build.dart
9191
- simple_data_asset/bin/simple_data_asset.dart.debug
92+
- simple_data_asset/bin/modify_data_asset.dart.debug
93+
- simple_data_asset/bin/deep_modify_data_asset.dart.debug
9294
- some_dev_dep/bin/some_dev_dep.dart
9395
- some_dev_dep/pubspec.yaml
9496
- wrong_build_output_2/hook/build.dart
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
import 'dart:asset';
5+
import 'dart:typed_data';
6+
7+
Future<void> main(List<String> args) async {
8+
print('Hello ${await getWorld()}');
9+
}
10+
11+
// Expect this to throw
12+
Future<String> getWorld() async {
13+
const asset = ByteAsset('package:simple_data_asset/assetId');
14+
final byteBuffer = await asset.load();
15+
byteBuffer.buffer.asFloat32List()[0] = 1.0;
16+
return String.fromCharCodes(byteBuffer);
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
import 'dart:asset';
5+
import 'dart:typed_data';
6+
7+
Future<void> main(List<String> args) async {
8+
print('Hello ${await getWorld()}');
9+
}
10+
11+
// Expect this to throw
12+
Future<String> getWorld() async {
13+
const asset = ByteAsset('package:simple_data_asset/assetId');
14+
final byteBuffer = await asset.load();
15+
byteBuffer[0] = 42;
16+
return String.fromCharCodes(byteBuffer);
17+
}

pkgs/native_assets_builder/test_data/simple_data_asset/bin/simple_data_asset.dart.debug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ Future<void> main(List<String> args) async {
1010
Future<String> getWorld() async {
1111
const asset = ByteAsset('package:simple_data_asset/assetId');
1212
final byteBuffer = await asset.load();
13-
return String.fromCharCodes(byteBuffer.asUint8List());
13+
return String.fromCharCodes(byteBuffer);
1414
}

0 commit comments

Comments
 (0)