-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
toString()
not escaping class names
Closes #3454
- Loading branch information
Showing
3 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import 'package:drift_dev/src/analysis/options.dart'; | ||
import 'package:drift_dev/src/writer/import_manager.dart'; | ||
import 'package:drift_dev/src/writer/utils/override_toString.dart'; | ||
import 'package:drift_dev/src/writer/writer.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
late Writer writer; | ||
|
||
setUp(() { | ||
final imports = LibraryImportManager(Uri.parse('drift:test')); | ||
final generationOptions = | ||
GenerationOptions(imports: imports, isModular: true); | ||
writer = Writer(const DriftOptions.defaults(), | ||
generationOptions: generationOptions); | ||
imports.linkToWriter(writer); | ||
}); | ||
|
||
test('overrides toString on class with dollar sign in name', () { | ||
overrideToString(r'$Foo', ['a', 'b'], writer.leaf().buffer); | ||
|
||
expect( | ||
writer.writeGenerated(), | ||
'@override\n' | ||
'String toString() {' | ||
r"return (StringBuffer('\$Foo(')..write('a: $a, ')..write('b: $b')..write(')')).toString();" | ||
'}\n'); | ||
}); | ||
} |