Repository: trag1c/crossandra (language: python)

Issue:
Fix SIGNED_NUMBER rule group
Because of being defined as `SIGNED_INT | SIGNED_FLOAT` it tokenizes `-1.0` as `-1` and fails on `.`


Discussion / hints:

Fix patch:
diff --git a/crossandra/common.py b/crossandra/common.py
index 1747a15..46e7e50 100644
--- a/crossandra/common.py
+++ b/crossandra/common.py
@@ -58,7 +58,7 @@ def float_(string: str) -> float:
 
 STRING: RuleGroup = SINGLE_QUOTED_STRING | DOUBLE_QUOTED_STRING
 """A string enclosed in either single or double quotes."""
-NUMBER: RuleGroup = INT | FLOAT
+NUMBER: RuleGroup = FLOAT | INT
 """A number (either an integer or a floating point value)."""
-SIGNED_NUMBER: RuleGroup = SIGNED_INT | SIGNED_FLOAT
+SIGNED_NUMBER: RuleGroup = SIGNED_FLOAT | SIGNED_INT
 """A signed number (either an integer or a floating point value)."""


Test patch:
diff --git a/tests/test_common.py b/tests/test_common.py
index dc73d4c..2523b67 100644
--- a/tests/test_common.py
+++ b/tests/test_common.py
@@ -15,11 +15,15 @@
     INT,
     LETTER,
     NEWLINE,
+    NUMBER,
     SIGNED_FLOAT,
     SIGNED_INT,
+    SIGNED_NUMBER,
     SINGLE_QUOTED_STRING,
+    STRING,
     WORD,
 )
+from crossandra.lib import Crossandra
 from crossandra.rule import NOT_APPLIED, Ignored, NotApplied
 
 # ESC = ESCAPED
@@ -66,7 +70,8 @@ def test_double_quoted_string(string: str, result: RuleResult) -> None:
     assert DOUBLE_QUOTED_STRING.apply(string) == result
 
 
-# test_STRING <=> test_SINGLE_QUOTED_STRING and test_DOUBLE_QUOTED_STRING
+def test_string() -> None:
+    assert Crossandra(rules=[STRING]).tokenize("'test'\"test\"") == ["'test'", '"test"']
 
 
 @pytest.mark.parametrize(
@@ -253,6 +258,9 @@ def test_signed_float(string: str, result: RuleResult) -> None:
     assert SIGNED_FLOAT.apply(string) == result
 
 
-# test_NUMBER <=> test_INT and test_FLOAT
+def test_number() -> None:
+    assert Crossandra(rules=[NUMBER]).tokenize("1.0") == [1.0]
 
-# test_SIGNED_NUMBER <=> test_SIGNED_INT and test_SIGNED_FLOAT
+
+def test_signed_number() -> None:
+    assert Crossandra(rules=[SIGNED_NUMBER]).tokenize("-1.0") == [-1.0]