-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.1.0 - Breaking change! copywith / change to, the Opt class has been…
… removed and now we favour the () => syntax for optional parameters 1.0.8 - change_to added for a subclass to change the type back to a superclass
- Loading branch information
Showing
20 changed files
with
286 additions
and
136 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import 'ex21_custom_constructors_test.dart' as A; | ||
|
||
main(){ | ||
A.A_Factory(); | ||
} |
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,42 @@ | ||
// ignore_for_file: unnecessary_cast | ||
// ignore_for_file: unused_element | ||
|
||
import 'package:morphy_annotation/morphy_annotation.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
part 'ex57_change_to_parent_test.morphy.dart'; | ||
|
||
main() { | ||
test("1 toJson", () { | ||
var aList = [ | ||
A(id: "1"), | ||
B(id: "2", blah: "sdf"), | ||
C(id: "3", xyz: "my custom"), | ||
]; | ||
|
||
var result = aList.map((e) => e.changeTo_A()).toList(); | ||
|
||
final expected = [ | ||
A(id: "1"), | ||
A(id: "2"), | ||
A(id: "3"), | ||
]; | ||
|
||
expect(result, expected); | ||
}); | ||
} | ||
|
||
@Morphy(explicitSubTypes: [$B, $C]) | ||
abstract class $A { | ||
String get id; | ||
} | ||
|
||
@Morphy() | ||
abstract class $B implements $A { | ||
String get blah; | ||
} | ||
|
||
@Morphy() | ||
abstract class $C implements $A { | ||
String get xyz; | ||
} |
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,46 @@ | ||
import 'package:morphy_annotation/morphy_annotation.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
part 'ex58_copywith_nullable.morphy.dart'; | ||
|
||
//nullable types and copyWith | ||
|
||
@morphy | ||
abstract class $Pet { | ||
String? get type; | ||
|
||
String get name; | ||
} | ||
|
||
main() { | ||
test("1", () { | ||
var a = Pet(type: "cat", name: "bob"); | ||
|
||
var expected = Pet(type: "cat", name: "bob"); | ||
expect(a, expected); | ||
|
||
//set type to null | ||
var a_copy = a.copyWith_Pet(type: () => null); | ||
|
||
var expected2 = Pet(type: null, name: "bob"); | ||
expect(a_copy, expected2); | ||
|
||
//copy just one param | ||
var a_copy3 = a.copyWith_Pet(name: () => "bobby"); | ||
|
||
var expected3 = Pet(type: "cat", name: "bobby"); | ||
expect(a_copy3, expected3); | ||
|
||
//set type to null initially | ||
var a4 = Pet(type: null, name: "bob"); | ||
|
||
var expected4 = Pet(type: null, name: "bob"); | ||
expect(a4, expected4); | ||
|
||
//type not specified | ||
var a5 = Pet(name: "bob"); | ||
|
||
var expected5 = Pet(type: null, name: "bob"); | ||
expect(a5, expected5); | ||
}); | ||
} |
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
Oops, something went wrong.