#389. Add more NNBD static semantics tests
diff --git a/LanguageFeatures/nnbd/static_errors_A01_t02.dart b/LanguageFeatures/nnbd/static_errors_A01_t02.dart
index 9d66e44..9dcf74e 100644
--- a/LanguageFeatures/nnbd/static_errors_A01_t02.dart
+++ b/LanguageFeatures/nnbd/static_errors_A01_t02.dart
@@ -22,11 +22,11 @@
}
test(C? c) {
-c.m; //# 01: compile-time error
-c.foo(); //# 02: compile-time error
-c.g; //# 03: compile-time error
-c.s = 2; //# 04: compile-time error
-c == new C(); //# 05: compile-time error
+ c.m; //# 01: compile-time error
+ c.foo(); //# 02: compile-time error
+ c.g; //# 03: compile-time error
+ c.s = 2; //# 04: compile-time error
+ c == new C(); //# 05: compile-time error
}
main() {
diff --git a/LanguageFeatures/nnbd/static_errors_A01_t03.dart b/LanguageFeatures/nnbd/static_errors_A01_t03.dart
index a610cd1..f516c3f 100644
--- a/LanguageFeatures/nnbd/static_errors_A01_t03.dart
+++ b/LanguageFeatures/nnbd/static_errors_A01_t03.dart
@@ -19,10 +19,10 @@
}
test(C? c) {
-Expect.isNotNull(c.hashCode);
-Expect.isNotNull(c.toString());
-Expect.isNotNull(c.runtimeType);
-Expect.isFalse(c == new C());
+ Expect.isNotNull(c.hashCode);
+ Expect.isNotNull(c.toString());
+ Expect.isNotNull(c.runtimeType);
+ Expect.isFalse(c == new C());
}
main() {
diff --git a/LanguageFeatures/nnbd/static_errors_A01_t04.dart b/LanguageFeatures/nnbd/static_errors_A01_t04.dart
index 04f69c7..61624375 100644
--- a/LanguageFeatures/nnbd/static_errors_A01_t04.dart
+++ b/LanguageFeatures/nnbd/static_errors_A01_t04.dart
@@ -30,5 +30,4 @@
main() {
test(new C());
- test(new C());
}
diff --git a/LanguageFeatures/nnbd/static_errors_A02_t01.dart b/LanguageFeatures/nnbd/static_errors_A02_t01.dart
new file mode 100644
index 0000000..6665f78
--- /dev/null
+++ b/LanguageFeatures/nnbd/static_errors_A02_t01.dart
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2019, 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 It is an error to read a field or tear off a method from an
+ * expression whose type is potentially nullable and not dynamic, except for the
+ * methods and fields on Object.
+ * @description Check that it is a compile-time error to read a field or tear
+ * off a method from an expression whose type is potentially nullable and not
+ * dynamic
+ * @author sgrekhov@unipro.ru
+ */
+// SharedOptions=--enable-experiment=non-nullable
+
+main() {
+ String? s = "Lily was";
+ int? i = 1;
+ double? d = 3.14;
+
+ (s + " here").substring(0); //# 01: compile-time error
+ (s + " here").length; //# 02: compile-time error
+ (i + i).isEven; //# 03: compile-time error
+ (d + i).abs(); //# 04: compile-time error
+}
diff --git a/LanguageFeatures/nnbd/static_errors_A02_t02.dart b/LanguageFeatures/nnbd/static_errors_A02_t02.dart
new file mode 100644
index 0000000..61969a8
--- /dev/null
+++ b/LanguageFeatures/nnbd/static_errors_A02_t02.dart
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2019, 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 It is an error to read a field or tear off a method from an
+ * expression whose type is potentially nullable and not dynamic, except for the
+ * methods and fields on Object.
+ * @description Check that it is no compile-time error to read a field or tear
+ * off a method from an expression whose type is potentially nullable but type
+ * dynamic
+ * @author sgrekhov@unipro.ru
+ */
+// SharedOptions=--enable-experiment=non-nullable
+
+testString(dynamic x) {
+ x.substring(0);
+ x.length;
+}
+
+testInt(dynamic x) {
+ x.abs();
+}
+
+main() {
+ String? s = "Lily was";
+ int? i = 1;
+ double? d = 3.14;
+
+ testString(s + " here");
+ testString(s + " here");
+ testInt(i + i);
+ testInt(d + i);
+}
diff --git a/LanguageFeatures/nnbd/static_errors_A02_t03.dart b/LanguageFeatures/nnbd/static_errors_A02_t03.dart
new file mode 100644
index 0000000..f376f0f
--- /dev/null
+++ b/LanguageFeatures/nnbd/static_errors_A02_t03.dart
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2019, 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 It is an error to read a field or tear off a method from an
+ * expression whose type is potentially nullable and not dynamic, except for the
+ * methods and fields on Object.
+ * @description Check that it is no compile-time error to read a field or tear
+ * off a method from an expression whose type is potentially nullable but they
+ * are methods and fields on Object
+ * @author sgrekhov@unipro.ru
+ */
+// SharedOptions=--enable-experiment=non-nullable
+
+main() {
+ String? s = "Lily was";
+ int? i = 1;
+ double? d = 3.14;
+
+ (s + " here").hashCode;
+ (s + " here").runtimeType;
+ (s + " here").toString();
+ (i + i).hashCode;
+ (i + i).runtimeType;
+ (d + i).toString();
+}