-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* test to cover all mentioned nullability issues * minor * minor * ci correction * use analyse action to output errors correctly to the CI dashboard actions * minor corrections * crashing dynamic test case * minor * show warnings from "dart run test" * Revert "show warnings from "dart run test"" This reverts commit f0d4ae3. * introspecting the class itself about the relevant constructors parameters * have ! only when the field of the class is non-nullable * Roll back feature with nullable field and non-nullable constructor. * tests + introducing an error when fields nullability not in sync with the constructor * remove question mark from dynamic input parameters * version bump
- Loading branch information
1 parent
4142dc3
commit 650b19c
Showing
15 changed files
with
143 additions
and
34 deletions.
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
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
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
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,34 @@ | ||
import 'package:copy_with_extension/copy_with_extension.dart'; | ||
import 'package:test/test.dart' show test, expect; | ||
|
||
part 'gen_nullability_test.g.dart'; | ||
|
||
@CopyWith() | ||
class TestNullability { | ||
TestNullability( | ||
this.dynamicField, | ||
this.integers, | ||
); | ||
|
||
/// https://github.com/numen31337/copy_with_extension/issues/74 | ||
/// Test for crash on `instance.dynamicField!`. | ||
final dynamic dynamicField; | ||
|
||
/// https://github.com/numen31337/copy_with_extension/issues/75 | ||
/// Warnings during compilation when using `!` on non-nullable value. | ||
/// Use `dart run copy_with_extension_gen/test/gen_nullability_test.dart` to reproduce the warning. | ||
final List<int> integers; | ||
} | ||
|
||
void main() { | ||
test('TestNullability', () { | ||
// Test for crash in both flows for `dynamicField`, when `dynamicField` is affected and not affected. | ||
expect(TestNullability(1, [1]).copyWith.integers([2]).dynamicField, 1); | ||
expect(TestNullability(1, [1]).copyWith.dynamicField(2).dynamicField, 2); | ||
expect(TestNullability(1, [1]).copyWith(dynamicField: 2).dynamicField, 2); | ||
expect(TestNullability(1, [1]).copyWith(integers: [1]).dynamicField, 1); | ||
expect(TestNullability(null, [1]).copyWith.dynamicField(1).dynamicField, 1); | ||
expect( | ||
TestNullability(null, [1]).copyWith.integers([2]).dynamicField, null); | ||
}); | ||
} |
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