@podlite/to-jsx 0.0.18 → 0.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,334 +0,0 @@
1
- use v6;
2
- use Test;
3
- plan 98;
4
- my ($r, $s);
5
-
6
- my $p = 0;
7
-
8
- #---
9
- =begin pod
10
- =begin code :allow<B>
11
- =end code
12
- =end pod
13
- #---
14
-
15
- $r = $=pod[$p++].contents[0];
16
- isa-ok $r, Pod::Block::Code;
17
- is $r.config<allow>, 'B';
18
-
19
- #---
20
- =begin pod
21
- =config head2 :like<head1> :formatted<I>
22
- =end pod
23
- #---
24
-
25
- $r = $=pod[$p++].contents[0];
26
- isa-ok $r, Pod::Config;
27
- is $r.type, 'head2';
28
- is $r.config<like>, 'head1';
29
- is $r.config<formatted>, 'I';
30
-
31
- #---
32
- =begin pod
33
- =for pod :number(42) :zebras :!sheep :feist<1 2 3 4>
34
- =end pod
35
- #---
36
-
37
- $r = $=pod[$p++].contents[0];
38
- is $r.config<number>, 42;
39
-
40
- { # RT#127085
41
- is-deeply $r.config<zebras>, True, 'bool config uses Bool type (True)';
42
- is-deeply $r.config<sheep>, False, 'bool config uses Bool type (False)';
43
- }
44
-
45
-
46
- # RT #124281
47
- isa-ok $r.config<feist>, Str;
48
-
49
-
50
- #---
51
- =begin pod
52
- =for DESCRIPTION :title<presentation template>
53
- = :author<John Brown> :pubdate(2011)
54
- =end pod
55
- #---
56
-
57
- $r = $=pod[$p++].contents[0];
58
- is $r.config<title>, 'presentation template';
59
- is $r.config<author>, 'John Brown';
60
- is $r.config<pubdate>, 2011;
61
-
62
- #---
63
- =begin pod
64
- =for table :caption<Table of contents>
65
- foo bar
66
- =end pod
67
- #---
68
-
69
- $r = $=pod[$p++].contents[0];
70
- isa-ok $r, Pod::Block::Table;
71
- is $r.config<caption>, 'Table of contents';
72
-
73
- #---
74
- =begin pod
75
- =begin code :allow<B>
76
- These words have some B<importance>.
77
- =end code
78
- =end pod
79
- #---
80
-
81
- $r = $=pod[$p++].contents[0].contents[1];
82
- isa-ok $r, Pod::FormattingCode;
83
-
84
- # Value is... Specify with... Or with... Or with...
85
- # =============== ======================= ================= ===========
86
- # List :key[$e1,$e2,...] :key($e1,$e2,...)
87
- # Hash :key{$k1=>$v1,$k2=>$v2}
88
- # Boolean (true) :key :key(True)
89
- # Boolean (false) :!key :key(False)
90
- # String :key<str> :key('str') :key("str")
91
- # Number :key(42) :key(2.3)
92
-
93
- # Where '$e1,$e2,...' are list elements of type Str, Int, Num, or
94
- # Bool. Lists may have mixed element types. Note that one-element
95
- # lists are converted to the type of their element (Str, Int, Num, or
96
- # Bool).
97
- #
98
- # For hashes, '$k1,$k2,...' are keys of type Str and '$v1,$2,...'
99
- # are values of type Str, Int, Num, or Bool.
100
-
101
- # Strings may use any of the single Q/q quote constructs, e.g.,
102
- # :key(Q[str]), which is equivalent to the :key<str> format and
103
- # results in an uninterpreted string literal.
104
-
105
- # tests for fixes for bugs:
106
- # RT #124281 - colonpairs in POD config options always produce strings
107
- # RT #126742 - config items should not include quotes for string values
108
- #
109
- # RT #130477 - Pod config parses colopairs but simply stringifies
110
- # whatever it matched
111
- #
112
- # RT #132632 - List and hash configuration value formats are not yet
113
- # implemented (NYI)
114
-
115
- #====================================================
116
- #=== strings
117
- #====================================================
118
- #---
119
- =begin table :k1<str> :k2('str') :k3("str") :k4["str"] :k5(Q[str])
120
- foo
121
- =end table
122
- #---
123
-
124
- $r = $=pod[$p++];
125
- say "=== testing strings";
126
- isa-ok $r.config<k1>, Str;
127
- isa-ok $r.config<k2>, Str;
128
- isa-ok $r.config<k3>, Str;
129
- isa-ok $r.config<k4>, Str;
130
- isa-ok $r.config<k5>, Str;
131
-
132
- $s = 'str';
133
- is $r.config<k1>, $s, Q|<str>|;
134
- is $r.config<k2>, $s, Q|'str'|;
135
- is $r.config<k3>, $s, Q|"str"|;
136
- is $r.config<k4>, $s, Q|"str"|;
137
- is $r.config<k4>, $s, Q|using a Q/q quote|;
138
-
139
- #====================================================
140
- #=== ints
141
- #====================================================
142
- # max val int (int32): +2_147_483_647 <= 10 digits
143
- # max val int (int64): +9_223_372_036_854_775_807 <= 19 digits
144
- # TODO make a dynamic test that changes config test with hardware int bit size
145
- #---
146
- =begin table :k1<1> :k2(2) :k3[2] :k4[+2000000000] :k5[-2000000000] :k6[+99999999999999999] :k7[-99999999999999999]
147
- foo
148
- =end table
149
- #---
150
-
151
- $r = $=pod[$p++];
152
- say "=== testing string and ints";
153
- isa-ok $r.config<k1>, Str;
154
- isa-ok $r.config<k2>, Int;
155
- isa-ok $r.config<k3>, Int;
156
- isa-ok $r.config<k4>, Int;
157
- isa-ok $r.config<k5>, Int;
158
- isa-ok $r.config<k6>, Int;
159
- isa-ok $r.config<k7>, Int;
160
-
161
- is $r.config<k1>, '1', Q|'1'|;
162
- is $r.config<k2>, 2, Q|2|;
163
- is $r.config<k3>, 2, Q|2|;
164
- is $r.config<k4>, 2_000_000_000, Q|+2000000000|;
165
- is $r.config<k5>, -2_000_000_000, Q|-2000000000|;
166
- # bigints with 18 digits each:
167
- is $r.config<k6>, +99999999999999999, Q|+99999999999999999|;
168
- is $r.config<k7>, -99999999999999999, Q|-99999999999999999|;
169
-
170
- #====================================================
171
- #=== nums
172
- #====================================================
173
-
174
- #---
175
- =begin table :k1(2.3) :k2[-2.3] :k3[+1e4] :k4(3.1e+04) :k5[-3.1E-04]
176
- foo
177
- =end table
178
- #---
179
-
180
- $r = $=pod[$p++];
181
- say "=== testing nums";
182
- isa-ok $r.config<k1>, Num;
183
- isa-ok $r.config<k2>, Num;
184
- isa-ok $r.config<k3>, Num;
185
- isa-ok $r.config<k4>, Num;
186
- isa-ok $r.config<k5>, Num;
187
-
188
- is $r.config<k1>, 2.3, Q|2.3|;
189
- is $r.config<k2>, -2.3, Q|-2.3|;
190
- is $r.config<k3>, +1e4, Q|+1e4|;
191
- is $r.config<k4>, 3.1e+04, Q|3.1e+04|;
192
- is $r.config<k5>, -3.1E-04, Q|-3.1E-04|;
193
-
194
- #====================================================
195
- #=== bools
196
- #====================================================
197
- #---
198
- =begin table :k1 :!k2 :k3(True) :k4[True] :k5(False) :k6[False]
199
- foo
200
- =end table
201
- #---
202
-
203
- $r = $=pod[$p++];
204
- say "=== testing booleans";
205
- isa-ok $r.config<k1>, Bool;
206
- isa-ok $r.config<k2>, Bool;
207
- isa-ok $r.config<k3>, Bool;
208
- isa-ok $r.config<k4>, Bool;
209
- isa-ok $r.config<k5>, Bool;
210
- isa-ok $r.config<k6>, Bool;
211
-
212
- ok $r.config<k1>, Q|:key|;
213
- nok $r.config<k2>, Q|:!key|;
214
- ok $r.config<k3>, Q|:key(True)|;
215
- ok $r.config<k4>, Q|:key[True]|;
216
- nok $r.config<k5>, Q|:key(False)|;
217
- nok $r.config<k6>, Q|:key[False]|;
218
-
219
- #====================================================
220
- #=== lists
221
- #====================================================
222
- say "=== testing lists";
223
- #---
224
- =begin table :k1(1, 'b c', 2.3, True, False) :k2[1, 'b c', 2.3, True, False]
225
- foo
226
- =end table
227
- #---
228
-
229
- $r = $=pod[$p++];
230
- isa-ok $r.config<k1>, List;
231
- isa-ok $r.config<k2>, List;
232
-
233
- is $r.config<k1>[0], 1, Q|1|;
234
- is $r.config<k1>[1], "b c", Q|'b c'|;
235
- is $r.config<k1>[2], 2.3, Q|2.3|;
236
- ok $r.config<k1>[3], Q|True|;
237
- nok $r.config<k1>[4], Q|False|;
238
-
239
- is $r.config<k2>[0], 1, Q|1|;
240
- is $r.config<k2>[1], "b c", Q|'b c'|;
241
- is $r.config<k2>[2], 2.3, Q|2.3|;
242
- ok $r.config<k2>[3], Q|True|;
243
- nok $r.config<k2>[4], Q|False|;
244
-
245
- #====================================================
246
- #=== hashes
247
- #====================================================
248
- say "=== testing hashes";
249
- #---
250
- =begin table :k1{a => 1, 2 => 'b', c => True, d => 2.3, e => False}
251
- foo
252
- =end table
253
- #---
254
-
255
- $r = $=pod[$p++];
256
- isa-ok $r.config<k1>, Hash;
257
-
258
- is $r.config<k1><a>, 1, Q|1|;
259
- is $r.config<k1><2>, 'b', Q|'b'|;
260
- ok $r.config<k1><c>, Q|True|;
261
- is $r.config<k1><d>, 2.3, Q|2.3|;
262
- nok $r.config<k1><e>, Q|False|;
263
-
264
- #====================================================
265
- #=== troublesome hashes
266
- #====================================================
267
- say "=== testing troublesome hashes";
268
- #---
269
- =begin table :k1{2 => 'b => ?', c => ",", d => 2.3}
270
- foo
271
- =end table
272
- #---
273
-
274
- $r = $=pod[$p++];
275
- isa-ok $r.config<k1>, Hash;
276
-
277
- is $r.config<k1><2>, 'b => ?', Q|'b => ?'|;
278
- is $r.config<k1><c>, ",", Q|","|;
279
- is $r.config<k1><d>, 2.3, Q|2.3|;
280
-
281
-
282
- =begin table :k1{2 , 'b => "', d => '"', 4 => "\""}
283
- foo
284
- =end table
285
-
286
- $r = $=pod[$p++];
287
- isa-ok $r.config<k1>, Hash;
288
-
289
- is $r.config<k1><2>, 'b => "', Q|'b => "'|;
290
- is $r.config<k1><d>, '"', Q|'"'|;
291
- is $r.config<k1><4>, "\"", Q|"\""|;
292
-
293
- #====================================================
294
- #=== bigints
295
- #====================================================
296
-
297
- # 30 digits
298
- #---
299
- =begin table :k6[+999999999999999999999999999999] :k7[-999999999999999999999999999999]
300
- foo
301
- =end table
302
- #---
303
- $r = $=pod[$p++];
304
- say "=== testing string and ints";
305
- # bigints with 30 digits each:
306
- isa-ok $r.config<k6>, Int;
307
- isa-ok $r.config<k7>, Int;
308
- is $r.config<k6>, 999_999_999_999_999_999_999_999_999_999, Q|+9 ** 30|;
309
- is $r.config<k7>, -999_999_999_999_999_999_999_999_999_999, Q|-9 ** 30|;
310
-
311
- #=====================================
312
- # GH issue #2793
313
- =for info :034foo
314
- :034foo
315
-
316
- $r = $=pod[$p++];
317
- isa-ok $r.config<foo>, Int, '034foo: foo => 34';
318
- is $r.config<foo>, 34, 'foo => 34';
319
-
320
-
321
- =for info :0foo
322
- :0foo
323
-
324
- $r = $=pod[$p++];
325
- isa-ok $r.config<foo>, Int, '0foo: foo => 0';
326
- is $r.config<foo>, 0, 'foo => 0';
327
-
328
- =for info :1foo
329
- :0foo
330
-
331
- $r = $=pod[$p++];
332
- isa-ok $r.config<foo>, Int, '1foo: foo => 1';
333
- is $r.config<foo>, 1, 'foo => 1';
334
-
@@ -1,20 +0,0 @@
1
- #---
2
- =begin pod
3
- =alias PROGNAME Earl Irradiatem Evermore
4
- =alias VENDOR 4D Kingdoms
5
- =alias TERMS_URLS =item L<http://www.4dk.com/eie>
6
- = =item L<http://www.4dk.co.uk/eie.io/>
7
- = =item L<http://www.fordecay.ch/canttouchthis>
8
- The use of A<PROGNAME> is subject to the terms and conditions
9
- laid out by A<VENDOR>, as specified at:
10
-
11
- A<TERMS_URLS>
12
-
13
- =end pod
14
- #---
15
-
16
- # A<>: wrap spaces around identifier #8
17
- #---
18
- =para
19
- A< TERER >
20
- #---
@@ -1,6 +0,0 @@
1
- #
2
- #---
3
- =para
4
- A D<formatting code|formatting codes;formatters> provides a way
5
- to add inline mark-up to a D<piece> of text.
6
- #---
@@ -1,4 +0,0 @@
1
- # Link E test
2
- #---
3
- =para E<171> xcxc E<0d171; 0o253; 0b10101011; 0xAB>
4
- #---
@@ -1,4 +0,0 @@
1
- # Link L test
2
- #---
3
- =item L<https://www.python.org/dev/peps/pep-0001/#what-is-a-pep>
4
- #---
@@ -1,16 +0,0 @@
1
- #---
2
- =begin pod
3
- =begin data :key<Virtues>
4
- Laziness
5
-
6
- Impatience
7
- Hubris
8
- =end data
9
- =data Industry
10
- =data Patience
11
- =data Humility
12
-
13
- say 'The three virtues are:';
14
- say $=data<Virtues>;
15
- =end pod
16
- #---
@@ -1,47 +0,0 @@
1
- import Podlite from '../src/index'
2
- import React from 'react'
3
- import { renderToStaticMarkup } from 'react-dom/server'
4
-
5
- const fs = require('fs')
6
- const path = require('path')
7
- const glob = require('glob')
8
-
9
- // load examples from fixtures src
10
- /**
11
- *
12
- * @returns
13
- * { file: '/Users/zag/Dropbox/Work/proj/podlite/packages/podlite-to-jsx/t/fixtures-src/00-maintests.t', 
14
- id: 5, 
15
- text: '=config table :k1<very long string, comma> :k2<2 23 23 > :k3<\'23\', 23233, 333>\n', 
16
- testFile: 't/fixtures/00-maintests_5.txt' }, 
17
- */
18
- const allSrcFixtures = () => {
19
- const pathToTests = path.resolve(__dirname, './fixtures-src')
20
- const files = glob.sync(`${pathToTests}/*.t`)
21
- const loaded = files
22
- .map(file => {
23
- const d = fs.readFileSync(file)
24
- const s = `${d}`
25
- .split(/#---+\n/)
26
- .filter(t => t.match(/^\s*=/))
27
- .map((text, i) => {
28
- const { dir, name } = path.parse(file)
29
- const testFile = `t/fixtures/${name}_${i}.txt`
30
- return { file, id: i, text, testFile }
31
- })
32
- return s
33
- })
34
- .flat()
35
- return loaded
36
- }
37
- const t = allSrcFixtures()
38
- t
39
-
40
- describe('run parser tests', () => {
41
- allSrcFixtures().map(i =>
42
- test(i.file, () => {
43
- const result = renderToStaticMarkup(<Podlite>{i.text}</Podlite>)
44
- expect(result).not.toBeNull()
45
- }),
46
- )
47
- })