aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/s-expressions/suites/InMem/ToBytes.yql
blob: aa9ed74d8fd979e999440b91538b0b0a438dd70f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
(
#comment
(let config (DataSource 'config))
(let world (Configure! world config 'PureDataSource 'yt))

(let res_sink (DataSink 'result))

(let test (lambda '(world data dataType) (block '(
  (let world (Write! world res_sink (Key) (ToBytes data) '('('type))))
  (let world (Write! world res_sink (Key) (FromBytes (ToBytes data) dataType) '('('type))))
  (return world)
))))

(let testEmpty (lambda '(world dataType) (block '(
  (let n (ToBytes (Nothing (OptionalType (DataType dataType)))))
  (let world (Write! world res_sink (Key) n '('('type))))
  (let world (Write! world res_sink (Key) (FromBytes n dataType) '('('type))))
  (return world)
))))

(let testFail (lambda '(world bytes dataType) (block '(
  (let world (Write! world res_sink (Key) (Exists (FromBytes bytes dataType)) '('('type))))
  (return world)
))))

(let world (Apply test world (Uint8 '7)                      'Uint8))
(let world (Apply test world (Bool 'True)                   'Bool))
(let world (Apply test world (Bool 'False)                  'Bool))
(let world (Apply test world (Int32 'x"abcdef12")           'Int32))
(let world (Apply test world (Int64 'x"71717171abcdef12")   'Int64))
(let world (Apply test world (Uint32 'x"abcdef12")          'Uint32))
(let world (Apply test world (Uint64 'x"ddddddddabcdef12")  'Uint64))
(let world (Apply test world (Float '2)                     'Float))
(let world (Apply test world (Double '2)                    'Double))
(let world (Apply test world (String '"abc")                'String))
(let world (Apply test world (Utf8 '"яндекс")               'Utf8))
(let world (Apply test world (Yson '"[1;2]")                'Yson))
(let world (Apply test world (Json '@@{"id":1}@@)           'Json))

(let world (Apply test world (Just (Uint8 '7))                     'Uint8))
(let world (Apply test world (Just (Bool 'True))                  'Bool))
(let world (Apply test world (Just (Bool 'False))                 'Bool))
(let world (Apply test world (Just (Int32 'x"abcdef12"))          'Int32))
(let world (Apply test world (Just (Int64 'x"71717171abcdef12"))  'Int64))
(let world (Apply test world (Just (Uint32 'x"abcdef12"))         'Uint32))
(let world (Apply test world (Just (Uint64 'x"ddddddddabcdef12")) 'Uint64))
(let world (Apply test world (Just (Float '2))                    'Float))
(let world (Apply test world (Just (Double '2))                   'Double))
(let world (Apply test world (Just (String '"abc"))               'String))
(let world (Apply test world (Just (Utf8 '"яндекс"))              'Utf8))
(let world (Apply test world (Just (Yson '"[1;2]"))               'Yson))
(let world (Apply test world (Just (Json '@@{"id":1}@@))          'Json))

(let world (Apply testEmpty world 'Uint8))
(let world (Apply testEmpty world 'Bool))
(let world (Apply testEmpty world 'Int32))
(let world (Apply testEmpty world 'Int64))
(let world (Apply testEmpty world 'Uint32))
(let world (Apply testEmpty world 'Uint64))
(let world (Apply testEmpty world 'Float))
(let world (Apply testEmpty world 'Double))
(let world (Apply testEmpty world 'String))
(let world (Apply testEmpty world 'Utf8))
(let world (Apply testEmpty world 'Yson))
(let world (Apply testEmpty world 'Json))

(let world (Apply testFail world (Nothing (OptionalType (DataType 'String))) 'Uint8))
(let world (Apply testFail world (Nothing (OptionalType (DataType 'String))) 'Bool))
(let world (Apply testFail world (Nothing (OptionalType (DataType 'String))) 'Int32))
(let world (Apply testFail world (Nothing (OptionalType (DataType 'String))) 'Int64))
(let world (Apply testFail world (Nothing (OptionalType (DataType 'String))) 'Uint32))
(let world (Apply testFail world (Nothing (OptionalType (DataType 'String))) 'Uint64))
(let world (Apply testFail world (Nothing (OptionalType (DataType 'String))) 'Float))
(let world (Apply testFail world (Nothing (OptionalType (DataType 'String))) 'Double))
(let world (Apply testFail world (Nothing (OptionalType (DataType 'String))) 'String))
(let world (Apply testFail world (String 'x"ffff")          'Utf8))
(let world (Apply testFail world (String '"][")             'Yson))
(let world (Apply testFail world (String '"}{")             'Json))

(let world (Commit! world res_sink))
(return world)
)