From 7aea3b548f446702897c04cb6766448ca31b609b Mon Sep 17 00:00:00 2001 From: Gabriel Volpe Date: Fri, 15 Oct 2021 14:06:05 +0200 Subject: [PATCH] add support for numbers in scientific notation --- data/scientific-notation.settings | 4 ++++ output/scientific-notation.nix | 15 +++++++++++++++ src/DConf.hs | 2 +- test/DConf2NixTest.hs | 10 ++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 data/scientific-notation.settings create mode 100644 output/scientific-notation.nix diff --git a/data/scientific-notation.settings b/data/scientific-notation.settings new file mode 100644 index 0000000..9c63a52 --- /dev/null +++ b/data/scientific-notation.settings @@ -0,0 +1,4 @@ +[com/github/wwmm/easyeffects/streamoutputs/bassenhancer] +amount=-6.9388939039072284e-16 +blend=0.0 +listen=true diff --git a/output/scientific-notation.nix b/output/scientific-notation.nix new file mode 100644 index 0000000..9ee834b --- /dev/null +++ b/output/scientific-notation.nix @@ -0,0 +1,15 @@ +# Generated via dconf2nix: https://github.com/gvolpe/dconf2nix +{ lib, ... }: + +with lib.hm.gvariant; + +{ + dconf.settings = { + "com/github/wwmm/easyeffects/streamoutputs/bassenhancer" = { + amount = -6.938893903907228e-16; + blend = 0.0; + listen = true; + }; + + }; +} diff --git a/src/DConf.hs b/src/DConf.hs index 51823d9..da83455 100644 --- a/src/DConf.hs +++ b/src/DConf.hs @@ -21,7 +21,7 @@ vDouble = try $ do s <- option "" $ string "-" n <- many1 digit d <- string "." - e <- many1 digit + e <- many1 (digit <|> oneOf "eEdD-") pure . D $ read (s <> n <> d <> e) vInt :: Parsec Text () Value diff --git a/test/DConf2NixTest.hs b/test/DConf2NixTest.hs index 5e276c7..74d68e4 100644 --- a/test/DConf2NixTest.hs +++ b/test/DConf2NixTest.hs @@ -106,5 +106,15 @@ dconf2nixKeybindings = prop_dconf2nix_keybindings :: Property prop_dconf2nix_keybindings = withTests (10 :: TestLimit) dconf2nixKeybindings +dconf2nixScientificNotation :: Property +dconf2nixScientificNotation = + let input = "data/scientific-notation.settings" + output = "output/scientific-notation.nix" + root = Root T.empty + in baseProperty input output root + +prop_dconf2nix_scientific_notation :: Property +prop_dconf2nix_scientific_notation = withTests (10 :: TestLimit) dconf2nixScientificNotation + dconf2nixTests :: Group dconf2nixTests = $$(discover)