@@ -635,7 +635,7 @@ def test_json_change_recursive_literal(config, syslog_ng):
635
635
def test_list_literal_becomes_syslogng_list_as_string (config , syslog_ng ):
636
636
(file_true , file_false ) = create_config (
637
637
config , """
638
- $MSG = json_array( ["foo", "bar", "baz"]) ;
638
+ $MSG = ["foo", "bar", "baz"];
639
639
""" ,
640
640
)
641
641
syslog_ng .start (config )
@@ -648,7 +648,7 @@ def test_list_literal_becomes_syslogng_list_as_string(config, syslog_ng):
648
648
def test_list_literal_becomes_json_list_as_a_part_of_json (config , syslog_ng ):
649
649
(file_true , file_false ) = create_config (
650
650
config , """
651
- $list = json_array( ["foo", "bar", "baz"]) ;
651
+ $list = ["foo", "bar", "baz"];
652
652
$MSG = json({
653
653
"key": "value",
654
654
"list": $list,
@@ -665,7 +665,7 @@ def test_list_literal_becomes_json_list_as_a_part_of_json(config, syslog_ng):
665
665
def test_list_is_cloned_upon_assignment (config , syslog_ng ):
666
666
(file_true , file_false ) = create_config (
667
667
config , """
668
- $list = json_array( ["foo", "bar", "baz"]) ;
668
+ $list = ["foo", "bar", "baz"];
669
669
$MSG = $list;
670
670
$list[0] = "changed foo";
671
671
$MSG[2] = "changed baz";
@@ -682,7 +682,7 @@ def test_list_is_cloned_upon_assignment(config, syslog_ng):
682
682
def test_list_subscript_without_index_appends_an_element (config , syslog_ng ):
683
683
(file_true , file_false ) = create_config (
684
684
config , """
685
- $list = json_array() ;
685
+ $list = [] ;
686
686
$list[] = "foo";
687
687
$list[] = "bar";
688
688
$list[] = "baz";
@@ -699,8 +699,8 @@ def test_list_subscript_without_index_appends_an_element(config, syslog_ng):
699
699
700
700
def test_literal_generator_assignment (config , syslog_ng ):
701
701
(file_true , file_false ) = create_config (
702
- config , """
703
- $MSG = json();
702
+ config , r """
703
+ $MSG = {}; # implicit json
704
704
$MSG.foo = {"answer": 42, "leet": 1337};
705
705
$MSG["bar"] = {"answer+1": 43, "leet+1": 1338};
706
706
$MSG.list = ["will be replaced"];
@@ -736,7 +736,7 @@ def test_literal_generator_casted_assignment(config, syslog_ng):
736
736
def test_function_call (config , syslog_ng ):
737
737
(file_true , file_false ) = create_config (
738
738
config , """
739
- $list = json_array() ;
739
+ $list = [] ;
740
740
$list[] = "foo";
741
741
$list[] = "bar";
742
742
$list[] = "baz";
@@ -1049,7 +1049,7 @@ def test_isset_inexisting_value_already_in_scope(config, syslog_ng):
1049
1049
def test_isset (config , syslog_ng ):
1050
1050
(file_true , file_false ) = create_config (
1051
1051
config , """
1052
- $MSG = json() ;
1052
+ $MSG = {} ;
1053
1053
$MSG.inner_key = "foo";
1054
1054
1055
1055
isset(${values.int});
@@ -1095,7 +1095,7 @@ def test_unset_value_already_in_scope(config, syslog_ng):
1095
1095
def test_unset_existing_key (config , syslog_ng ):
1096
1096
(file_true , file_false ) = create_config (
1097
1097
config , """
1098
- $MSG = json() ;
1098
+ $MSG = {} ;
1099
1099
$MSG["foo"] = "bar";
1100
1100
unset($MSG["foo"]);
1101
1101
not isset($MSG["foo"]);
@@ -1111,7 +1111,7 @@ def test_unset_existing_key(config, syslog_ng):
1111
1111
def test_unset_inexisting_key (config , syslog_ng ):
1112
1112
(file_true , file_false ) = create_config (
1113
1113
config , """
1114
- $MSG = json() ;
1114
+ $MSG = {} ;
1115
1115
unset($MSG["foo"]);
1116
1116
not isset($MSG["foo"]);
1117
1117
""" ,
@@ -1126,7 +1126,7 @@ def test_unset_inexisting_key(config, syslog_ng):
1126
1126
def test_setting_an_unset_key_will_contain_the_right_value (config , syslog_ng ):
1127
1127
(file_true , file_false ) = create_config (
1128
1128
config , """
1129
- $MSG = json() ;
1129
+ $MSG = {} ;
1130
1130
$MSG["foo"] = "first";
1131
1131
unset($MSG["foo"]);
1132
1132
not isset($MSG["foo"]);
@@ -1143,9 +1143,9 @@ def test_setting_an_unset_key_will_contain_the_right_value(config, syslog_ng):
1143
1143
def test_unset (config , syslog_ng ):
1144
1144
(file_true , file_false ) = create_config (
1145
1145
config , """
1146
- $MSG = json() ;
1146
+ $MSG = {} ;
1147
1147
$MSG["inner_key"] = "foo";
1148
- $arr = json_array() ;
1148
+ $arr = [] ;
1149
1149
$arr[] = "first";
1150
1150
$arr[] = "second";
1151
1151
@@ -1206,8 +1206,8 @@ def test_strptime_failure_result(config, syslog_ng):
1206
1206
def test_len (config , syslog_ng ):
1207
1207
(file_true , file_false ) = create_config (
1208
1208
config , r"""
1209
- $dict = json() ;
1210
- $list = json_array() ;
1209
+ $dict = {} ;
1210
+ $list = [] ;
1211
1211
len($dict) == 0;
1212
1212
len($list) == 0;
1213
1213
@@ -1248,7 +1248,7 @@ def test_regexp_match(config, syslog_ng):
1248
1248
def test_regexp_nomatch (config , syslog_ng ):
1249
1249
(file_true , file_false ) = create_config (
1250
1250
config , r"""
1251
- $MSG = json() ;
1251
+ $MSG = {} ;
1252
1252
$MSG.match = ${values.str} !~ /string/;
1253
1253
$MSG.match_any = ${values.str} !~ /.*/;
1254
1254
$MSG.nomatch = ${values.str} !~ /wrong/;
@@ -1284,7 +1284,7 @@ def test_regexp_match_error_in_pattern(config, syslog_ng):
1284
1284
def test_regexp_search (config , syslog_ng ):
1285
1285
(file_true , file_false ) = create_config (
1286
1286
config , r"""
1287
- $MSG = json() ;
1287
+ $MSG = {} ;
1288
1288
$MSG.unnamed = regexp_search("foobarbaz", /(foo)(bar)(baz)/);
1289
1289
$MSG.named = regexp_search("foobarbaz", /(?<first>foo)(?<second>bar)(?<third>baz)/);
1290
1290
$MSG.mixed = regexp_search("foobarbaz", /(?<first>foo)(bar)(?<third>baz)/);
@@ -1322,7 +1322,7 @@ def test_regexp_search(config, syslog_ng):
1322
1322
def test_regexp_search_error_in_pattern (config , syslog_ng ):
1323
1323
_ = create_config (
1324
1324
config , r"""
1325
- $MSG = json( regexp_search("foo", /(/) );
1325
+ $MSG = regexp_search("foo", /(/);
1326
1326
""" ,
1327
1327
)
1328
1328
with pytest .raises (Exception ):
@@ -1412,7 +1412,7 @@ def test_parse_csv_optional_arg_columns(config, syslog_ng):
1412
1412
(file_true , file_false ) = create_config (
1413
1413
config , """
1414
1414
custom_message = "foo,bar,baz";
1415
- cols = json_array( ["1st","2nd","3rd"]) ;
1415
+ cols = ["1st","2nd","3rd"];
1416
1416
$MSG = parse_csv(custom_message, columns=cols);
1417
1417
""" ,
1418
1418
)
@@ -1441,7 +1441,7 @@ def test_parse_csv_optional_arg_non_greedy(config, syslog_ng):
1441
1441
(file_true , file_false ) = create_config (
1442
1442
config , """
1443
1443
custom_message = "foo,bar,baz,tik,tak,toe";
1444
- cols = json_array( ["1st","2nd","3rd"]) ;
1444
+ cols = ["1st","2nd","3rd"];
1445
1445
$MSG = parse_csv(custom_message, columns=cols, greedy=false);
1446
1446
""" ,
1447
1447
)
@@ -1456,7 +1456,7 @@ def test_parse_csv_optional_arg_greedy(config, syslog_ng):
1456
1456
(file_true , file_false ) = create_config (
1457
1457
config , """
1458
1458
custom_message = "foo,bar,baz,tik,tak,toe";
1459
- cols = json_array( ["1st","2nd","3rd","rest"]) ;
1459
+ cols = ["1st","2nd","3rd","rest"];
1460
1460
$MSG = parse_csv(custom_message, columns=cols, greedy=true);
1461
1461
""" ,
1462
1462
)
@@ -1519,19 +1519,19 @@ def test_vars(config, syslog_ng):
1519
1519
def test_unset_empties (config , syslog_ng ):
1520
1520
(file_true , file_false ) = create_config (
1521
1521
config , r"""
1522
- dict = json( {"foo": "", "bar": "-", "baz": "N/A", "almafa": null, "kortefa": {"a":{"s":{"d":{}}}}, "szilvafa": [[[]]]}) ;
1522
+ dict = {"foo": "", "bar": "-", "baz": "N/A", "almafa": null, "kortefa": {"a":{"s":{"d":{}}}}, "szilvafa": [[[]]]};
1523
1523
defaults_dict = dict;
1524
1524
explicit_dict = dict;
1525
1525
unset_empties(defaults_dict);
1526
1526
unset_empties(explicit_dict, recursive=true);
1527
1527
1528
- list = json_array( ["", "-", "N/A", null, {"a":{"s":{"d":{}}}}, [[[]]]]) ;
1528
+ list = ["", "-", "N/A", null, {"a":{"s":{"d":{}}}}, [[[]]]];
1529
1529
defaults_list = list;
1530
1530
explicit_list = list;
1531
1531
unset_empties(defaults_list);
1532
1532
unset_empties(explicit_list, recursive=true);
1533
1533
1534
- $MSG = json_array( [defaults_dict, explicit_dict, defaults_list, explicit_list]) ;
1534
+ $MSG = [defaults_dict, explicit_dict, defaults_list, explicit_list];
1535
1535
""" ,
1536
1536
)
1537
1537
syslog_ng .start (config )
@@ -1573,10 +1573,10 @@ def test_null_coalesce_use_default_on_error_and_supress_error(config, syslog_ng)
1573
1573
def test_null_coalesce_get_happy_paths (config , syslog_ng ):
1574
1574
(file_true , file_false ) = create_config (
1575
1575
config , r"""
1576
- data = json( {"foo":"1", "bar":"2", "baz":"3"}) ;
1576
+ data = {"foo":"1", "bar":"2", "baz":"3"};
1577
1577
def = "default";
1578
1578
key = "bar";
1579
- $MSG = json() ;
1579
+ $MSG = {} ;
1580
1580
1581
1581
$MSG.a = data[key] ?? def;
1582
1582
$MSG.b = key ?? def;
@@ -1592,7 +1592,7 @@ def = "default";
1592
1592
def test_null_coalesce_get_subscript_error (config , syslog_ng ):
1593
1593
(file_true , file_false ) = create_config (
1594
1594
config , r"""
1595
- data = json( {"foo":"1", "bar":"2", "baz":"3"}) ;
1595
+ data = {"foo":"1", "bar":"2", "baz":"3"};
1596
1596
def = "default";
1597
1597
key = "missing_key";
1598
1598
$MSG = data[key] ?? def;
@@ -1608,7 +1608,7 @@ def = "default";
1608
1608
def test_null_coalesce_use_nested_coalesce (config , syslog_ng ):
1609
1609
(file_true , file_false ) = create_config (
1610
1610
config , r"""
1611
- data = json( {"foo":"1", "bar":"2", "baz":"3"}) ;
1611
+ data = {"foo":"1", "bar":"2", "baz":"3"};
1612
1612
def = "default";
1613
1613
key1 = "missing_key1";
1614
1614
key2 = "missing_key2";
@@ -1625,7 +1625,7 @@ def = "default";
1625
1625
def test_null_coalesce_use_nested_coalesce_return_mid_match (config , syslog_ng ):
1626
1626
(file_true , file_false ) = create_config (
1627
1627
config , r"""
1628
- data = json( {"foo":"1", "bar":"2", "baz":"3"}) ;
1628
+ data = {"foo":"1", "bar":"2", "baz":"3"};
1629
1629
def = "default";
1630
1630
key1 = "missing_key1";
1631
1631
key2 = "baz";
@@ -1642,7 +1642,7 @@ def = "default";
1642
1642
def test_null_coalesce_do_not_supress_last_error (config , syslog_ng ):
1643
1643
(file_true , file_false ) = create_config (
1644
1644
config , r"""
1645
- data = json( {"foo":"1", "bar":"2", "baz":"3"}) ;
1645
+ data = {"foo":"1", "bar":"2", "baz":"3"};
1646
1646
def = "default";
1647
1647
key1 = "missing_key1";
1648
1648
key2 = "missing_key2";
@@ -1659,9 +1659,9 @@ def = "default";
1659
1659
def test_null_coalesce_precedence_versus_ternary (config , syslog_ng ):
1660
1660
(file_true , file_false ) = create_config (
1661
1661
config , r"""
1662
- data = json( {"foo":"1", "bar":"2", "baz":"3"}) ;
1662
+ data = {"foo":"1", "bar":"2", "baz":"3"};
1663
1663
def = "default";
1664
- $MSG = json() ;
1664
+ $MSG = {} ;
1665
1665
1666
1666
# according to c# and python null coalesce have higher precedence
1667
1667
@@ -1689,7 +1689,7 @@ def = "default";
1689
1689
1690
1690
def test_slash_string_features (config , syslog_ng ):
1691
1691
cfg = r"""
1692
- $MSG = json() ;
1692
+ $MSG = {} ;
1693
1693
$MSG.base = /foo bar/;
1694
1694
$MSG.line_break = /foo
1695
1695
bar/;
@@ -1749,7 +1749,7 @@ def test_slash_string_features(config, syslog_ng):
1749
1749
def test_regexp_subst (config , syslog_ng ):
1750
1750
(file_true , file_false ) = create_config (
1751
1751
config , r"""
1752
- $MSG = json() ;
1752
+ $MSG = {} ;
1753
1753
$MSG.single = regexp_subst("foobarbaz","o","");
1754
1754
$MSG.empty_string = regexp_subst("","a","!");
1755
1755
$MSG.empty_pattern = regexp_subst("foobarbaz","","!");
@@ -1798,7 +1798,7 @@ def test_regexp_subst_all_args_are_mandatory(config, syslog_ng):
1798
1798
def test_add_operator_for_base_types (config , syslog_ng ):
1799
1799
(file_true , file_false ) = create_config (
1800
1800
config , r"""
1801
- $MSG = json() ;
1801
+ $MSG = {} ;
1802
1802
$MSG.string = "foo" + "bar" + "baz";
1803
1803
$MSG.bytes = string(bytes("\xCA") + bytes("\xFE"));
1804
1804
$MSG.datetime_integer = string(strptime("2000-01-01T00:00:00Z", "%Y-%m-%dT%H:%M:%S%z") + 3600000000);
@@ -1807,11 +1807,11 @@ def test_add_operator_for_base_types(config, syslog_ng):
1807
1807
$MSG.integer_double = 3 + 0.5;
1808
1808
$MSG.double_integer = 3.5 + 2;
1809
1809
$MSG.double_double = 3.14 + 0.86;
1810
- js1 = json_array( ["foo","bar"]) ;
1811
- js2 = json_array( ["baz","other"]) ;
1810
+ js1 = ["foo","bar"];
1811
+ js2 = ["baz","other"];
1812
1812
$MSG.list_list = js1 + js2;
1813
- dict1 = json( {"foo":"bar"}) ;
1814
- dict2 = json( {"baz":"other"}) ;
1813
+ dict1 = {"foo":"bar"};
1814
+ dict2 = {"baz":"other"};
1815
1815
$MSG.dict_dict = dict1 + dict2;
1816
1816
""" ,
1817
1817
)
@@ -1837,15 +1837,15 @@ def test_add_operator_for_base_types(config, syslog_ng):
1837
1837
def test_flatten (config , syslog_ng ):
1838
1838
(file_true , file_false ) = create_config (
1839
1839
config , r"""
1840
- dict = json( {"top_level_field":42,"top_level_dict":{"inner_field":1337,"inner_dict":{"inner_inner_field":1}}}) ;
1840
+ dict = {"top_level_field":42,"top_level_dict":{"inner_field":1337,"inner_dict":{"inner_inner_field":1}}};
1841
1841
1842
1842
default_separator = dict;
1843
1843
custom_separator = dict;
1844
1844
1845
1845
flatten(default_separator);
1846
1846
flatten(custom_separator, separator="->");
1847
1847
1848
- $MSG = json_array( [default_separator, custom_separator]) ;
1848
+ $MSG = [default_separator, custom_separator];
1849
1849
""" ,
1850
1850
)
1851
1851
syslog_ng .start (config )
@@ -1861,14 +1861,14 @@ def test_flatten(config, syslog_ng):
1861
1861
def test_add_operator_for_generators (config , syslog_ng ):
1862
1862
(file_true , file_false ) = create_config (
1863
1863
config , r"""
1864
- $MSG = json() ;
1865
- js1 = json_array( ["foo","bar"]) ;
1866
- js2 = json_array( ["baz","other"]) ;
1864
+ $MSG = {} ;
1865
+ js1 = ["foo","bar"];
1866
+ js2 = ["baz","other"];
1867
1867
$MSG.list_var_gen = js1 + ["baz1","other1"];
1868
1868
$MSG.list_gen_var = ["foo2", "bar2"] + js2;
1869
1869
$MSG.list_gen_gen = ["foo3", "bar3"] + ["baz3", "other3"];
1870
- dict1 = json( {"foo":{"bar":"baz"}}) ;
1871
- dict2 = json( {"tik":{"tak":"toe"}}) ;
1870
+ dict1 = {"foo":{"bar":"baz"}};
1871
+ dict2 = {"tik":{"tak":"toe"}};
1872
1872
$MSG.dict_var_gen = dict1 + {"tik1":{"tak1":"toe1"}};
1873
1873
$MSG.dict_gen_var = {"foo2":{"bar2":"baz2"}} + dict2;
1874
1874
$MSG.dict_gen_gen = {"foo3":{"bar3":"baz3"}} + {"tik3":{"tak3":"toe3"}};
@@ -1892,9 +1892,9 @@ def test_add_operator_for_generators(config, syslog_ng):
1892
1892
def test_plus_equal_grammar_rules (config , syslog_ng ):
1893
1893
(file_true , file_false ) = create_config (
1894
1894
config , r"""
1895
- $MSG = json() ;
1896
- js1 = json_array( ["foo","bar"]) ;
1897
- js2 = json_array( ["baz","other"]) ;
1895
+ $MSG = {} ;
1896
+ js1 = ["foo","bar"];
1897
+ js2 = ["baz","other"];
1898
1898
1899
1899
a = 3;
1900
1900
a += 2;
0 commit comments