Exemplo n.º 1
0
 def test_full(self):
     declarations({
         "match": {
             "param": {
                 "pattern": "string",
                 "subject": "string",
                 "flags": {
                     'bit-sum':
                     ["PREG_OFFSET_CAPTURE", "PREG_UNMATCHED_AS_NULL"]
                 },
                 "matches": ["string[]", "optional", "&ref"],
                 "offset": ["int", "optional", "&ref"]
             },
             "return-type": "int"
         },
         "match_all": {
             "param": {
                 "pattern": "string",
                 "subject": "string",
                 "matches": ["array[]", "optional", "&ref"],
                 "flags": {
                     'bit-sum': [
                         "PREG_PATTERN_ORDER", "PREG_SET_ORDER",
                         "PREG_OFFSET_CAPTURE", "PREG_UNMATCHED_AS_NULL"
                     ]
                 },
                 "offset": ["int", "optional", "&ref"]
             },
             "template": {
                 "a": ["string", "string[]"]
             },
             "return-type": "int"
         },
     })
Exemplo n.º 2
0
def build_details(summaries: dict = None,
                  params: dict = None,
                  links: dict = None) -> dict:
    validate.definitions(summaries) if summaries else {}
    validate.declarations(params) if params else {}
    validate.decorations(links) if links else {}

    dictionaries = merge_dictionaries([
        build_params(params or {}),
        build_links(links or {}),
        build_summaries(summaries or {})
    ],
                                      allow_override=False)
    return polyfill_methods(dictionaries)
Exemplo n.º 3
0
 def test_raise_on_invalid_param(self):
     self.assertRaises(SchemaError,
                       lambda: declarations({"match": {
                           "param": {
                               "a": 2
                           }
                       }}))
Exemplo n.º 4
0
 def test_raise_on_invalid_template_param_list(self):
     self.assertRaises(
         SchemaError,
         lambda: declarations({"match": {
             "template": {
                 "T": [2]
             }
         }}))
Exemplo n.º 5
0
 def test_empty_template(self):
     declarations({"match": {"template": {"T": []}}})
Exemplo n.º 6
0
 def test_single_type_template(self):
     declarations({"match": {"template": {"T": "string"}}})
Exemplo n.º 7
0
 def test_empty_param(self):
     declarations({"match": {"param": {}}})
Exemplo n.º 8
0
 def test_empty_first_level(self):
     declarations({"match": {}})
Exemplo n.º 9
0
 def test_empty(self):
     declarations({})