-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from MercuryTechnologies/tad/generic-newtype-test
Propagate 'Codable' bounds through MoatData tyvars
- Loading branch information
Showing
10 changed files
with
116 additions
and
13 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,3 @@ | ||
@Parcelize | ||
@Serializable | ||
value class LTree<A : Parcelable>(val value: List<A>) : Parcelable |
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,4 @@ | ||
data class Tree<A : Parcelable>( | ||
val rootLabel: A, | ||
val subForest: List<Tree<A>>, | ||
) : Parcelable |
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,4 @@ | ||
struct LTree<A: Hashable & Codable>: Hashable, Codable { | ||
typealias LTreeTag = Tagged<LTree, [A]> | ||
let value: LTreeTag | ||
} |
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,4 @@ | ||
struct Tree<A: Hashable & Codable>: Hashable, Codable { | ||
var rootLabel: A | ||
var subForest: [Tree<A>] | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
struct Data<A, B>: CaseIterable, Hashable, Codable { | ||
struct Data<A: Hashable & Codable, B: Hashable & Codable>: CaseIterable, Hashable, Codable { | ||
var field0: A | ||
var field1: B | ||
} |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
struct Data<A>: CaseIterable, Hashable, Codable { | ||
struct Data<A: Hashable & Codable>: CaseIterable, Hashable, Codable { | ||
var field0: A | ||
} |
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,33 @@ | ||
{-# LANGUAGE DerivingStrategies #-} | ||
|
||
module GenericNewtypeSpec where | ||
|
||
import Common | ||
import Data.List.NonEmpty (NonEmpty) | ||
import Moat | ||
import Test.Hspec | ||
import Test.Hspec.Golden | ||
import Prelude | ||
|
||
newtype LTree a = LTree (NonEmpty a) | ||
deriving stock (Show, Eq) | ||
|
||
mobileGenWith | ||
( defaultOptions | ||
{ dataAnnotations = [Parcelize, Serializable] | ||
, dataInterfaces = [Parcelable] | ||
, dataProtocols = [Hashable, Codable] | ||
, dataRawValue = Just Str | ||
, generateDocComments = False | ||
} | ||
) | ||
''LTree | ||
|
||
spec :: Spec | ||
spec = | ||
describe "stays golden" $ do | ||
let moduleName = "GenericNewtypeSpec" | ||
it "swift" $ | ||
defaultGolden ("swift" <> moduleName) (showSwift @(LTree _)) | ||
it "kotlin" $ | ||
defaultGolden ("kotlin" <> moduleName) (showKotlin @(LTree _)) |
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,28 @@ | ||
{-# OPTIONS_GHC -Wno-orphans #-} | ||
|
||
module GenericStructSpec where | ||
|
||
import Common | ||
import Data.Tree (Tree) | ||
import Moat | ||
import Test.Hspec | ||
import Test.Hspec.Golden | ||
import Prelude | ||
|
||
mobileGenWith | ||
( defaultOptions | ||
{ dataInterfaces = [Parcelable] | ||
, dataProtocols = [Hashable, Codable] | ||
, generateDocComments = False | ||
} | ||
) | ||
''Tree | ||
|
||
spec :: Spec | ||
spec = | ||
describe "stays golden" $ do | ||
let moduleName = "GenericStructSpec" | ||
it "swift" $ | ||
defaultGolden ("swift" <> moduleName) (showSwift @(Tree _)) | ||
it "kotlin" $ | ||
defaultGolden ("kotlin" <> moduleName) (showKotlin @(Tree _)) |