Skip to content

Commit

Permalink
Use non-default option when testing file-scope options.
Browse files Browse the repository at this point in the history
  • Loading branch information
chungyc committed Oct 2, 2024
1 parent c8460da commit fffa57d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions proto-lens-tests/tests/edition2023_fileoptions.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ edition = "2023";
package edition2023_fileoptions;

// In edition 2023, the default for field presence is EXPLICIT.
option features.field_presence = EXPLICIT;
option features.field_presence = IMPLICIT;

message FeatureOverrides {
// This inherit the EXPLICIT file option.
// This inherits the IMPLICIT file option.
int32 field_presence = 1;

message Sub {
Expand Down
13 changes: 7 additions & 6 deletions proto-lens-tests/tests/edition2023_test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import Data.ProtoLens
import Lens.Family2 ((&), (.~), (^.))
import qualified Data.ByteString.Builder as Builder
import Test.Tasty (testGroup)
import Test.Tasty.HUnit (assertFailure, testCase, (@=?))
import Test.Tasty.HUnit (assertFailure, testCase, (@=?), (@?=))

import Proto.Edition2023
( Defaults
Expand Down Expand Up @@ -89,7 +89,7 @@ main = testMain
, testGroup "Explicitly specified features"
[ testGroup "field_presence"
[ testCase "EXPLICIT" $
(defFeatures ^. maybe'fieldPresenceExplicit) @=? Nothing
(defFeatures ^. maybe'fieldPresenceExplicit) @?= Nothing

, testCase "IMPLICIT" $
defFeatures @=? (defFeatures & fieldPresenceImplicit .~ 0)
Expand Down Expand Up @@ -187,11 +187,12 @@ main = testMain
]

, testGroup "Feature overrides from file options"
[ testCase "EXPLICIT field presence passed to field" $
((defMessage :: FeatureOverrides) ^. O.maybe'fieldPresence) @=? Nothing
[ testCase "IMPLICIT field presence passed to field" $
((defMessage :: FeatureOverrides) & O.fieldPresence .~ 0) @?= defMessage

, testCase "EXPLICIT field presence passed through nested message type" $
((defMessage :: FeatureOverrides) ^. O.sub . O.maybe'fieldPresence) @=? Nothing
, testCase "IMPLICIT field presence passed through nested message type" $
((defMessage :: FeatureOverrides) & O.sub . O.fieldPresence .~ 0) @?=
(defMessage & O.sub .~ defMessage)
]
]

Expand Down

0 comments on commit fffa57d

Please sign in to comment.