Explorar o código

init dart test case

石头哥哥 %!s(int64=5) %!d(string=hai) anos
achega
e9bf66cc63
Modificáronse 9 ficheiros con 93 adicións e 0 borrados
  1. 13 0
      .gitignore
  2. 3 0
      CHANGELOG.md
  3. 5 0
      README.md
  4. 14 0
      analysis_options.yaml
  5. 17 0
      lib/Bicycle.dart
  6. 16 0
      lib/main.dart
  7. 3 0
      lib/xdart_test.dart
  8. 14 0
      pubspec.yaml
  9. 8 0
      test/xdart_test_test.dart

+ 13 - 0
.gitignore

@@ -0,0 +1,13 @@
+# Files and directories created by pub
+.dart_tool/
+.packages
+# Remove the following pattern if you wish to check in your lock file
+pubspec.lock
+
+# Conventional directory for build outputs
+build/
+
+# Directory created by dartdoc
+doc/api/
+
+.idea

+ 3 - 0
CHANGELOG.md

@@ -0,0 +1,3 @@
+## 1.0.0
+
+- Initial version, created by Stagehand

+ 5 - 0
README.md

@@ -0,0 +1,5 @@
+A sample command-line application with an entrypoint in `bin/`, library code
+in `lib/`, and example unit test in `test/`.
+
+Created from templates made available by Stagehand under a BSD-style
+[license](https://github.com/dart-lang/stagehand/blob/master/LICENSE).

+ 14 - 0
analysis_options.yaml

@@ -0,0 +1,14 @@
+# Defines a default set of lint rules enforced for
+# projects at Google. For details and rationale,
+# see https://github.com/dart-lang/pedantic#enabled-lints.
+include: package:pedantic/analysis_options.yaml
+
+# For lint rules and documentation, see http://dart-lang.github.io/linter/lints.
+# Uncomment to specify additional rules.
+# linter:
+#   rules:
+#     - camel_case_types
+
+analyzer:
+#   exclude:
+#     - path/to/excluded/files/**

+ 17 - 0
lib/Bicycle.dart

@@ -0,0 +1,17 @@
+class Bicycle {
+  int age;
+
+  Bicycle({this.age});
+
+  factory Bicycle.fromJson(Map<String, dynamic> json) {
+    return Bicycle(
+      age: json['age'],
+    );
+  }
+
+  Map<String, dynamic> toJson() {
+    final Map<String, dynamic> data = new Map<String, dynamic>();
+    data['age'] = this.age;
+    return data;
+  }
+}

+ 16 - 0
lib/main.dart

@@ -0,0 +1,16 @@
+import 'package:xdart_test/Bicycle.dart';
+import 'package:xdart_test/xdart_test.dart' as c_test;
+
+//
+void main(List<String> arguments) {
+  for (var arg in arguments) {
+    print(arg);
+  }
+  var bike = Bicycle(age: 100);
+  var info = bike.toString();
+  var json = bike.toJson();
+  print('bike info:$json');
+  var num = 100;
+  print('this is num:$num');
+  print('Hello world: ${c_test.calculate()}!');
+}

+ 3 - 0
lib/xdart_test.dart

@@ -0,0 +1,3 @@
+int calculate() {
+  return 56 * 7;
+}

+ 14 - 0
pubspec.yaml

@@ -0,0 +1,14 @@
+name: xdart_test
+description: A sample command-line application.
+# version: 1.0.0
+# homepage: https://www.example.com
+
+environment:
+  sdk: '>=2.7.0 <3.0.0'
+
+#dependencies:
+#  path: ^1.6.0
+
+dev_dependencies:
+  pedantic: ^1.8.0
+  test: ^1.6.0

+ 8 - 0
test/xdart_test_test.dart

@@ -0,0 +1,8 @@
+import 'package:test/test.dart';
+import 'package:xdart_test/xdart_test.dart';
+
+void main() {
+  test('calculate', () {
+    expect(calculate(), 392);
+  });
+}