Exemple #1
0
def test_inline():
    parse = load_parser()
    a = parse('''
    type Point = {
        x : int32;
        y : int32
    }

    type Space = {
        a: Point;
        b: Point
    }

    ''')

    a = parse('''
    type Person = {
        name   : string;
        age    : int;
        height : int;
        weight : int
    }

    type RGBA = {
        r: int32;
        g: int32;
        b: int32;
        a: int8
    }
    ''')
Exemple #2
0
def test_inline():
    parse = load_parser()
    a = parse('''
    type Point = {
        x : int32;
        y : int32
    }

    type Space = {
        a: Point;
        b: Point
    }

    ''')

    a = parse('''
    type Person = {
        name   : string;
        age    : int;
        height : int;
        weight : int
    }

    type RGBA = {
        r: int32;
        g: int32;
        b: int32;
        a: int8
    }
    ''')
Exemple #3
0
def test_parameterized():
    parse = load_parser()
    a = parse('''
    type T x y = {
        a: x;
        b: y
    }
    ''')
Exemple #4
0
def test_nested():
    parse = load_parser()
    a = parse('''
    type Space = {
        a: { x: int; y: int };
        b: { x: int; y: int }
    }
    ''')
Exemple #5
0
def test_parameterized():
    parse = load_parser()
    a = parse('''
    type T x y = {
        a: x;
        b: y
    }
    ''')
Exemple #6
0
def test_nested():
    parse = load_parser()
    a = parse('''
    type Space = {
        a: { x: int; y: int };
        b: { x: int; y: int }
    }
    ''')
Exemple #7
0
def test_all_the_strings():
    parse = load_parser()
    parse('a')
    parse('a, b')
    parse('a, b, c')
    parse('a,      b')
    parse('a,      b  ,     d')
    parse('800, 600, RGBA')
    parse('type foo = c')
    parse('type foo    =    c')
    parse('type a b c = d,e,f')
    parse('type   a b c = d, e   ')
    parse('type foo a b = c, d')
    parse('type foo a b = c,d,e')
    parse('type foo a b = c,d,e,   f')
    parse('type foo a b = c,   d,   e,   f')
    parse('type foo b = c,   d,   e,   f')
    parse('type a b c = d, e')
    parse('type a b c = bar, foo')
    parse('type bar A = A')
    parse('type bar A = A, B')
    parse('type bar A = 800, 600, A, A')
    parse('type bar A B = 800, 600, A, B')
    parse('type bar A B = {}')
    parse('type bar A B = {A:B}')

    #parse('type baz = F(A,B)')
    #parse('type baz = F(A,F(A))')

    parse('''
    type foo = {
        A: B;
        C: D;
        E: (A,B)
    }
    ''')

    parse('''
    type bar a b = {
        A : B;
        C : D;
        E : (a,b)
    }
    ''')

    parse('type empty = {} ')

    parse('''
    type Stock = {
      name   : string;
      min    : int64;
      max    : int64;
      mid    : int64;
      volume : float;
      close  : float;
      open   : float
    }
    ''')
Exemple #8
0
def test_all_the_strings():
    parse = load_parser()
    parse('a')
    parse('a, b')
    parse('a, b, c')
    parse('a,      b')
    parse('a,      b  ,     d')
    parse('800, 600, RGBA')
    parse('type foo = c')
    parse('type foo    =    c')
    parse('type a b c = d,e,f')
    parse('type   a b c = d, e   ')
    parse('type foo a b = c, d')
    parse('type foo a b = c,d,e')
    parse('type foo a b = c,d,e,   f')
    parse('type foo a b = c,   d,   e,   f')
    parse('type foo b = c,   d,   e,   f')
    parse('type a b c = d, e')
    parse('type a b c = bar, foo')
    parse('type bar A = A')
    parse('type bar A = A, B')
    parse('type bar A = 800, 600, A, A')
    parse('type bar A B = 800, 600, A, B')
    parse('type bar A B = {}')
    parse('type bar A B = {A:B}')

    #parse('type baz = F(A,B)')
    #parse('type baz = F(A,F(A))')

    parse('''
    type foo = {
        A: B;
        C: D;
        E: (A,B)
    }
    ''')

    parse('''
    type bar a b = {
        A : B;
        C : D;
        E : (a,b)
    }
    ''')

    parse('type empty = {} ')

    parse('''
    type Stock = {
      name   : string;
      min    : int64;
      max    : int64;
      mid    : int64;
      volume : float;
      close  : float;
      open   : float
    }
    ''')
Exemple #9
0
def test_multiline():
    parse = load_parser()
    a = parse('''

    type f a = b
    type g a = b

    type a = {
        a: int;
        b: float;
        c: (5,int32);
    }

    ''')
Exemple #10
0
def test_multiline():
    parse = load_parser()
    a = parse('''

    type f a = b
    type g a = b

    type a = {
        a: int;
        b: float;
        c: (5,int32);
    }

    ''')
Exemple #11
0
def test_stress():
    parse = load_parser()
    parse('type big = Union(Union(Union(Union(Union(Union(Union(Union(x)))))))) ')
    parse('type big = {x:{x:{x:{x:{x:{x:{x:{x:{x:{x:int32}}}}}}}}}}')

    # whitespace insensitivity
    parse('''type big = {
            x:{         x
                :{
                        x:
            {x:{x:
                {x:{x:{  x:{x
        :{x
        :int32
            }}}
                }}    }}}}}
    ''')
Exemple #12
0
def test_trailing_semi():
    parse = load_parser()
    a = parse('''
    type a = {
        a: int;
        b: float;
        c: (5,int32)
    }
    ''')

    b = parse('''
    type a = {
        a: int;
        b: float;
        c: (5,int32);
    }
    ''')

    assert a == b
Exemple #13
0
def test_stress():
    parse = load_parser()
    parse(
        'type big = Union(Union(Union(Union(Union(Union(Union(Union(x)))))))) '
    )
    parse('type big = {x:{x:{x:{x:{x:{x:{x:{x:{x:{x:int32}}}}}}}}}}')

    # whitespace insensitivity
    parse('''type big = {
            x:{         x
                :{
                        x:
            {x:{x:
                {x:{x:{  x:{x
        :{x
        :int32
            }}}
                }}    }}}}}
    ''')
Exemple #14
0
def test_trailing_semi():
    parse = load_parser()
    a = parse('''
    type a = {
        a: int;
        b: float;
        c: (5,int32)
    }
    ''')

    b = parse('''
    type a = {
        a: int;
        b: float;
        c: (5,int32);
    }
    ''')

    assert a == b
Exemple #15
0
def test_option():
    parse = load_parser()
    a = parse(''' Option(int32) ''')
Exemple #16
0
def test_either3():
    parse = load_parser()
    a = parse(''' Either( (2, 2, T), (T, 2, int) ) ''')
Exemple #17
0
def test_either2():
    parse = load_parser()
    a = parse(''' Either({x: int}, {y: float}) ''')
Exemple #18
0
def test_either3():
    parse = load_parser()
    a = parse(''' Either( (2, 2, T), (T, 2, int) ) ''')
Exemple #19
0
def test_either2():
    parse = load_parser()
    a = parse(''' Either({x: int}, {y: float}) ''')
Exemple #20
0
def test_either1():
    parse = load_parser()
    a = parse(''' Either(int32, float32) ''')
Exemple #21
0
def test_union():
    parse = load_parser()
    a = parse(''' Union(a,b,c,d) ''')
Exemple #22
0
def test_either1():
    parse = load_parser()
    a = parse(''' Either(int32, float32) ''')
Exemple #23
0
def test_option():
    parse = load_parser()
    a = parse(''' Option(int32) ''')
Exemple #24
0
def test_union():
    parse = load_parser()
    a = parse(''' Union(a,b,c,d) ''')