Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(611)

Unified Diff: pkg/observe/test/transform_test.dart

Issue 23742002: Fix observable transform bug introduced in a recent change, add regression tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/observe/lib/transform.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/observe/test/transform_test.dart
diff --git a/pkg/observe/test/transform_test.dart b/pkg/observe/test/transform_test.dart
index 1222b25e932c67b6fb2103c8c5a231a2977ad91d..9a64fac07102607b229c510c7eb7b57a1c39d114 100644
--- a/pkg/observe/test/transform_test.dart
+++ b/pkg/observe/test/transform_test.dart
@@ -46,6 +46,18 @@ main() {
_testInitializers('this.a, [this.b]', '(a, [b]) : __\$a = a, __\$b = b');
_testInitializers('this.a, {this.b}', '(a, {b}) : __\$a = a, __\$b = b');
});
+
+ group('test full text', () {
+ test('with changes', () {
+ return _transform(_sampleObservable('A', 'foo'))
+ .then((output) => expect(output, _sampleObservableOutput('A', 'foo')));
+ });
+
+ test('no changes', () {
+ var input = 'class A {/*@observable annotation to trigger transform */;}';
+ return _transform(input).then((output) => expect(output, input));
+ });
+ });
}
_testClause(String clauses, String expected) {
@@ -118,3 +130,28 @@ class _MockTransform implements Transform {
outs.add(output);
}
}
+
+String _sampleObservable(String className, String fieldName) => '''
+library ${className}_$fieldName;
+import 'package:observe/observe.dart';
+
+class $className extends ObservableBase {
+ @observable int $fieldName;
+ $className(this.$fieldName);
+}
+''';
+
+String _sampleObservableOutput(String className, String fieldName) => '''
+library ${className}_$fieldName;
+import 'package:observe/observe.dart';
+
+class $className extends ChangeNotifierBase {
+ int __\$$fieldName;
+ int get $fieldName => __\$$fieldName;
+ set $fieldName(int value) {
+ __\$$fieldName = notifyPropertyChange(const Symbol('$fieldName'), __\$$fieldName, value);
+ }
+
+ $className($fieldName) : __\$$fieldName = $fieldName;
+}
+''';
« no previous file with comments | « pkg/observe/lib/transform.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698