Skip to content

Commit

Permalink
polishing emoji work before cutting release
Browse files Browse the repository at this point in the history
  • Loading branch information
gvolpe committed Oct 17, 2022
1 parent 9e2e61c commit 9b44d67
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
1 change: 1 addition & 0 deletions data/emoji.settings
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[ org/gnome/Characters ]
recent-characters=['💡']
some-other-character=['🤓']
emoji-in-double-quotes=["🔥"]
1 change: 1 addition & 0 deletions output/emoji.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ with lib.hm.gvariant;
{
dconf.settings = {
"org/gnome/Characters" = {
emoji-in-double-quotes = [ "🔥" ];
recent-characters = [ "💡" ];
some-other-character = [ "🤓" ];
};
Expand Down
12 changes: 8 additions & 4 deletions src/DConf.hs
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,15 @@ vString parser = try $ do
vAny :: Parsec Text () Value
vAny = S . T.pack <$> manyTill anyChar (try $ lookAhead endOfLine)

emojiParser :: EmojiSupport -> [Parsec Text () Value]
emojiParser Enabled = [vEmoji]
emojiParser Disabled = []

dconf :: EmojiSupport -> Parser -> Parsec Text () Value
dconf Enabled p = choice
[vBool, vInt, vDouble, vUint32, vInt64, vEmptyString, vEmoji, vString p, vTuple Enabled, vAny]
dconf Disabled p = choice
[vBool, vInt, vDouble, vUint32, vInt64, vEmptyString, vString p, vTuple Disabled, vAny]
dconf es p =
let xs = [vBool, vInt, vDouble, vUint32, vInt64, vEmptyString]
ys = [vString p, vTuple es, vAny]
in choice (xs ++ emojiParser es ++ ys)

-- There is no support for variants in HM yet so we parse them as a string
vListOfVariant :: Parsec Text () Value
Expand Down
23 changes: 13 additions & 10 deletions test/DConf2NixTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import Text.Parsec ( runParser )
prop_dconf2nix :: Property
prop_dconf2nix = withTests (10 :: TestLimit) dconf2nix

baseProperty' :: FilePath -> FilePath -> Root -> Property
baseProperty' i o root = baseProperty i o root Disabled

baseProperty :: FilePath -> FilePath -> Root -> EmojiSupport -> Property
baseProperty i o root es = property $ do
input <- evalIO $ T.readFile i
Expand All @@ -34,7 +37,7 @@ dconf2nix =
let input = "data/dconf.settings"
output = "output/dconf.nix"
root = Root T.empty
in baseProperty input output root Disabled
in baseProperty' input output root

prop_dconf2nix_custom_root :: Property
prop_dconf2nix_custom_root = withTests (10 :: TestLimit) dconf2nixCustomRoot
Expand All @@ -44,7 +47,7 @@ dconf2nixCustomRoot =
let input = "data/custom.settings"
output = "output/custom.nix"
root = Root "ca/desrt/dconf-editor"
in baseProperty input output root Disabled
in baseProperty' input output root

prop_dconf2nix_custom_nested_root :: Property
prop_dconf2nix_custom_nested_root =
Expand All @@ -55,14 +58,14 @@ dconf2nixCustomNestedRoot =
let input = "data/nested.settings"
output = "output/nested.nix"
root = Root "org/gnome/desktop/peripherals"
in baseProperty input output root Disabled
in baseProperty' input output root

dconf2nixIndexer :: Property
dconf2nixIndexer =
let input = "data/indexer.settings"
output = "output/indexer.nix"
root = Root T.empty
in baseProperty input output root Disabled
in baseProperty' input output root

prop_dconf2nix_indexer :: Property
prop_dconf2nix_indexer = withTests (10 :: TestLimit) dconf2nixIndexer
Expand All @@ -72,7 +75,7 @@ dconf2nixNegative =
let input = "data/negative.settings"
output = "output/negative.nix"
root = Root T.empty
in baseProperty input output root Disabled
in baseProperty' input output root

prop_dconf2nix_negative :: Property
prop_dconf2nix_negative = withTests (10 :: TestLimit) dconf2nixNegative
Expand All @@ -82,7 +85,7 @@ dconf2nixJson =
let input = "data/json.settings"
output = "output/json.nix"
root = Root T.empty
in baseProperty input output root Disabled
in baseProperty' input output root

prop_dconf2nix_json :: Property
prop_dconf2nix_json = withTests (10 :: TestLimit) dconf2nixJson
Expand All @@ -92,7 +95,7 @@ dconf2nixClocks =
let input = "data/clocks.settings"
output = "output/clocks.nix"
root = Root T.empty
in baseProperty input output root Disabled
in baseProperty' input output root

prop_dconf2nix_clocks :: Property
prop_dconf2nix_clocks = withTests (10 :: TestLimit) dconf2nixClocks
Expand All @@ -102,7 +105,7 @@ dconf2nixKeybindings =
let input = "data/keybindings.settings"
output = "output/keybindings.nix"
root = Root T.empty
in baseProperty input output root Disabled
in baseProperty' input output root

prop_dconf2nix_keybindings :: Property
prop_dconf2nix_keybindings = withTests (10 :: TestLimit) dconf2nixKeybindings
Expand All @@ -112,7 +115,7 @@ dconf2nixScientificNotation =
let input = "data/scientific-notation.settings"
output = "output/scientific-notation.nix"
root = Root T.empty
in baseProperty input output root Disabled
in baseProperty' input output root

prop_dconf2nix_scientific_notation :: Property
prop_dconf2nix_scientific_notation =
Expand All @@ -123,7 +126,7 @@ dconf2nixHeaders =
let input = "data/headers.settings"
output = "output/headers.nix"
root = Root T.empty
in baseProperty input output root Disabled
in baseProperty' input output root

prop_dconf2nix_headers :: Property
prop_dconf2nix_headers =
Expand Down

0 comments on commit 9b44d67

Please sign in to comment.