Skip to content

Commit

Permalink
dart-lang#2556. Initial commit for macros tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrekhov committed Mar 5, 2024
1 parent 3e12dd0 commit 8abb315
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 0 deletions.
27 changes: 27 additions & 0 deletions LanguageFeatures/macros/macros_lib.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// @assertion
///
/// @description Checks
/// @author [email protected]
// SharedOptions=--enable-experiment=macros

library macro_lib;

import 'dart:async';
import 'package:_fe_analyzer_shared/src/macros/api.dart';

macro class AddTypeMacro implements LibraryTypesMacro {
final String className;
const AddTypeMacro() : className = "DefaultTypeMacroAddedClass";
const AddTypeMacro.name(this.className);

FutureOr<void> buildTypesForLibrary(Library library, TypeBuilder builder) {
//print(library.uri);
DeclarationCode code = DeclarationCode.fromString("class $className {}");
builder.declareType(className, code);
}
}
102 changes: 102 additions & 0 deletions LanguageFeatures/macros/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: co19_macros
description: co19 tests for macros feature
publish_to: none

environment:
sdk: '>=3.3.0-279.1.beta <4.0.0'

dev_dependencies:
args: ^2.3.0
benchmark_harness: ^2.2.1
checks: ^0.2.0
test: ^1.24.0
dart_style: ^2.2.1
_fe_analyzer_shared: any

# Override to the latest version of the in progress api.
dependency_overrides:
_fe_analyzer_shared:
git:
url: https://github.com/dart-lang/sdk.git
path: pkg/_fe_analyzer_shared
ref: main
_js_interop_checks:
git:
url: https://github.com/dart-lang/sdk.git
path: pkg/_js_interop_checks
ref: main
analyzer:
git:
url: https://github.com/dart-lang/sdk.git
path: pkg/analyzer
ref: main
build_integration:
git:
url: https://github.com/dart-lang/sdk.git
path: pkg/build_integration
ref: main
compiler:
git:
url: https://github.com/dart-lang/sdk.git
path: pkg/compiler
ref: main
dart2js_info:
git:
url: https://github.com/dart-lang/sdk.git
path: pkg/dart2js_info
ref: main
dart2wasm:
git:
url: https://github.com/dart-lang/sdk.git
path: pkg/dart2wasm
ref: main
dev_compiler:
git:
url: https://github.com/dart-lang/sdk.git
path: pkg/dev_compiler
ref: main
front_end:
git:
url: https://github.com/dart-lang/sdk.git
path: pkg/front_end
ref: main
frontend_server:
git:
url: https://github.com/dart-lang/sdk.git
path: pkg/frontend_server
ref: main
js_ast:
git:
url: https://github.com/dart-lang/sdk.git
path: pkg/js_ast
ref: main
js_runtime:
git:
url: https://github.com/dart-lang/sdk.git
path: pkg/js_runtime
ref: main
js_shared:
git:
url: https://github.com/dart-lang/sdk.git
path: pkg/js_shared
ref: main
kernel:
git:
url: https://github.com/dart-lang/sdk.git
path: pkg/kernel
ref: main
mmap:
git:
url: https://github.com/dart-lang/sdk.git
path: pkg/mmap
ref: main
vm:
git:
url: https://github.com/dart-lang/sdk.git
path: pkg/vm
ref: main
wasm_builder:
git:
url: https://github.com/dart-lang/sdk.git
path: pkg/wasm_builder
ref: main
19 changes: 19 additions & 0 deletions LanguageFeatures/macros/test_A01_t01.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// @assertion
///
/// @description Checks
/// @author [email protected]
// SharedOptions=--enable-experiment=macros

@AddTypeMacro()
library;

import 'macros_lib.dart';

main() {
print(DefaultTypeMacroAddedClass);
}

0 comments on commit 8abb315

Please sign in to comment.