edn_turbo 0.3.1 → 0.3.2
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.
- checksums.yaml +4 -4
- data/README.md +9 -4
- data/bin/ppedn +3 -1
- data/ext/edn_turbo/edn_parser.cc +1337 -946
- data/ext/edn_turbo/edn_parser.h +27 -13
- data/ext/edn_turbo/edn_parser.rl +207 -145
- data/ext/edn_turbo/edn_parser_util.cc +56 -47
- data/ext/edn_turbo/main.cc +20 -17
- data/lib/edn_turbo/constants.rb +14 -0
- data/lib/edn_turbo/edn_parser.rb +5 -2
- data/lib/edn_turbo/tags.rb +46 -0
- data/lib/edn_turbo/utils.rb +34 -0
- data/lib/edn_turbo/version.rb +2 -2
- data/lib/edn_turbo.rb +10 -92
- data/test/test_output_diff.rb +56 -26
- metadata +6 -3
@@ -1,5 +1,7 @@
|
|
1
1
|
#include <iostream>
|
2
2
|
#include <string>
|
3
|
+
#include <stack>
|
4
|
+
#include <vector>
|
3
5
|
#include <limits>
|
4
6
|
#include <exception>
|
5
7
|
|
@@ -30,18 +32,23 @@ namespace edn
|
|
30
32
|
//
|
31
33
|
VALUE Parser::next()
|
32
34
|
{
|
33
|
-
VALUE token =
|
35
|
+
VALUE token = EDNT_EOF_CONST;
|
34
36
|
|
35
37
|
while (!is_eof())
|
36
38
|
{
|
37
39
|
// fetch a token. If it's metadata or discard
|
38
|
-
VALUE v;
|
39
|
-
|
40
|
-
|
40
|
+
VALUE v = EDNT_EOF_CONST;
|
41
|
+
eTokenState state = parse_next(v);
|
42
|
+
|
43
|
+
if (state == TOKEN_OK) {
|
41
44
|
// valid token
|
42
45
|
token = v;
|
43
46
|
break;
|
44
47
|
}
|
48
|
+
else if (state == TOKEN_ERROR) {
|
49
|
+
token = EDNT_EOF_CONST;
|
50
|
+
break;
|
51
|
+
}
|
45
52
|
}
|
46
53
|
|
47
54
|
return token;
|
@@ -53,7 +60,13 @@ namespace edn
|
|
53
60
|
{
|
54
61
|
line_number = 1;
|
55
62
|
discard.clear();
|
56
|
-
|
63
|
+
|
64
|
+
// remove any remaining levels except for the first
|
65
|
+
while (metadata.size() > 1) {
|
66
|
+
del_top_meta_list();
|
67
|
+
}
|
68
|
+
// but clear any metadata on the first
|
69
|
+
metadata.top()->clear();
|
57
70
|
}
|
58
71
|
|
59
72
|
//
|
@@ -76,20 +89,27 @@ namespace edn
|
|
76
89
|
|
77
90
|
// we're using at most 2 args
|
78
91
|
struct prot_args {
|
79
|
-
prot_args(
|
92
|
+
prot_args(VALUE r, ID m) :
|
93
|
+
receiver(r), method(m), count(0) {
|
94
|
+
}
|
95
|
+
prot_args(VALUE r, ID m, VALUE arg) :
|
80
96
|
receiver(r), method(m), count(1) {
|
81
97
|
args[0] = arg;
|
82
98
|
}
|
83
|
-
prot_args(
|
99
|
+
prot_args(VALUE r, ID m, VALUE arg1, VALUE arg2) :
|
84
100
|
receiver(r), method(m), count(2) {
|
85
101
|
args[0] = arg1;
|
86
102
|
args[1] = arg2;
|
87
103
|
}
|
88
104
|
|
89
|
-
VALUE call() const {
|
105
|
+
VALUE call() const {
|
106
|
+
return ((count == 0) ?
|
107
|
+
rb_funcall( receiver, method, 0 ) :
|
108
|
+
rb_funcall2( receiver, method, count, args ));
|
109
|
+
}
|
90
110
|
|
91
111
|
private:
|
92
|
-
|
112
|
+
VALUE receiver;
|
93
113
|
ID method;
|
94
114
|
VALUE count;
|
95
115
|
VALUE args[2];
|
@@ -133,29 +153,35 @@ namespace edn
|
|
133
153
|
// hold, call into ruby to get a big num
|
134
154
|
VALUE Parser::integer_to_ruby(const char* str, std::size_t len)
|
135
155
|
{
|
136
|
-
if (len
|
156
|
+
if (str[len-1] == 'M' || len >= LL_max_chars)
|
137
157
|
{
|
138
|
-
|
158
|
+
std::string buf(str, len);
|
159
|
+
VALUE vs = edn_prot_rb_new_str(buf.c_str());
|
160
|
+
prot_args args(vs, EDNT_STRING_TO_I_METHOD);
|
161
|
+
return edn_prot_rb_funcall( edn_wrap_funcall2, reinterpret_cast<VALUE>(&args) );
|
139
162
|
}
|
140
163
|
|
141
|
-
|
142
|
-
VALUE rb_s = edn_prot_rb_new_str( str );
|
143
|
-
prot_args args(rb_mEDNT, EDNT_STR_INT_TO_BIGNUM, rb_s);
|
144
|
-
return edn_prot_rb_funcall( edn_wrap_funcall2, reinterpret_cast<VALUE>(&args) );
|
164
|
+
return LONG2NUM(buftotype<long>(str, len));
|
145
165
|
}
|
146
166
|
|
147
167
|
//
|
148
168
|
// as above.. TODO: check exponential..
|
149
169
|
VALUE Parser::float_to_ruby(const char* str, std::size_t len)
|
150
170
|
{
|
151
|
-
if (len
|
171
|
+
if (str[len-1] == 'M' || len >= LD_max_chars)
|
152
172
|
{
|
153
|
-
|
173
|
+
std::string buf(str, len);
|
174
|
+
VALUE vs = edn_prot_rb_new_str(buf.c_str());
|
175
|
+
|
176
|
+
if (str[len-1] == 'M') {
|
177
|
+
return Parser::make_edn_type(EDNT_MAKE_BIG_DECIMAL_METHOD, vs);
|
178
|
+
}
|
179
|
+
|
180
|
+
prot_args args(vs, EDNT_STRING_TO_F_METHOD);
|
181
|
+
return edn_prot_rb_funcall( edn_wrap_funcall2, reinterpret_cast<VALUE>(&args) );
|
154
182
|
}
|
155
183
|
|
156
|
-
|
157
|
-
prot_args args(rb_mEDNT, EDNT_STR_DBL_TO_BIGNUM, edn_prot_rb_new_str(str));
|
158
|
-
return edn_prot_rb_funcall( edn_wrap_funcall2, reinterpret_cast<VALUE>(&args) );
|
184
|
+
return rb_float_new(buftotype<double>(str, len));
|
159
185
|
}
|
160
186
|
|
161
187
|
|
@@ -218,25 +244,15 @@ namespace edn
|
|
218
244
|
|
219
245
|
//
|
220
246
|
// get a set representation from the ruby side. See edn_turbo.rb
|
221
|
-
VALUE Parser::
|
247
|
+
VALUE Parser::make_edn_type(ID method, VALUE sym)
|
222
248
|
{
|
223
|
-
prot_args args(rb_mEDNT,
|
249
|
+
prot_args args(rb_mEDNT, method, sym);
|
224
250
|
return edn_prot_rb_funcall( edn_wrap_funcall2, reinterpret_cast<VALUE>(&args) );
|
225
251
|
}
|
226
252
|
|
227
|
-
|
228
|
-
// get a set representation from the ruby side. See edn_turbo.rb
|
229
|
-
VALUE Parser::make_ruby_set(VALUE elems)
|
253
|
+
VALUE Parser::make_edn_type(ID method, VALUE name, VALUE data)
|
230
254
|
{
|
231
|
-
prot_args args(rb_mEDNT,
|
232
|
-
return edn_prot_rb_funcall( edn_wrap_funcall2, reinterpret_cast<VALUE>(&args) );
|
233
|
-
}
|
234
|
-
|
235
|
-
//
|
236
|
-
// get an object representation from the ruby side using the given symbol name
|
237
|
-
VALUE Parser::tagged_element(VALUE name, VALUE data)
|
238
|
-
{
|
239
|
-
prot_args args(rb_mEDNT, EDNT_TAGGED_ELEM, name, data);
|
255
|
+
prot_args args(rb_mEDNT, method, name, data);
|
240
256
|
return edn_prot_rb_funcall( edn_wrap_funcall2, reinterpret_cast<VALUE>(&args) );
|
241
257
|
}
|
242
258
|
|
@@ -248,22 +264,15 @@ namespace edn
|
|
248
264
|
// (right to left) - the ruby side will interpret this
|
249
265
|
VALUE Parser::ruby_meta()
|
250
266
|
{
|
251
|
-
VALUE
|
267
|
+
VALUE m_ary = rb_ary_new();
|
252
268
|
|
253
|
-
|
254
|
-
|
255
|
-
metadata.
|
269
|
+
// pop from the back of the top-most list
|
270
|
+
while (!metadata.top()->empty()) {
|
271
|
+
rb_ary_push(m_ary, metadata.top()->back());
|
272
|
+
metadata.top()->pop_back();
|
256
273
|
}
|
257
274
|
|
258
|
-
return
|
259
|
-
}
|
260
|
-
|
261
|
-
//
|
262
|
-
// calls the ruby-side bind_meta to bind the metadata to the value
|
263
|
-
VALUE Parser::bind_meta_to_value(VALUE value)
|
264
|
-
{
|
265
|
-
prot_args args(rb_mEDNT, EDNT_BIND_META_TO_VALUE, value, ruby_meta());
|
266
|
-
return edn_prot_rb_funcall( edn_wrap_funcall2, reinterpret_cast<VALUE>(&args) );
|
275
|
+
return m_ary;
|
267
276
|
}
|
268
277
|
|
269
278
|
|
data/ext/edn_turbo/main.cc
CHANGED
@@ -12,15 +12,18 @@ namespace edn {
|
|
12
12
|
VALUE rb_mEDNT;
|
13
13
|
|
14
14
|
// methods on the ruby side we'll call from here
|
15
|
-
VALUE
|
16
|
-
VALUE
|
17
|
-
VALUE
|
18
|
-
VALUE
|
19
|
-
VALUE
|
20
|
-
VALUE
|
15
|
+
VALUE EDNT_MAKE_SYMBOL_METHOD = Qnil;
|
16
|
+
VALUE EDNT_MAKE_LIST_METHOD = Qnil;
|
17
|
+
VALUE EDNT_MAKE_SET_METHOD = Qnil;
|
18
|
+
VALUE EDNT_MAKE_BIG_DECIMAL_METHOD = Qnil;
|
19
|
+
VALUE EDNT_TAGGED_ELEM_METHOD = Qnil;
|
20
|
+
VALUE EDNT_EXTENDED_VALUE_METHOD = Qnil;
|
21
|
+
|
22
|
+
VALUE EDNT_STRING_TO_I_METHOD = Qnil;
|
23
|
+
VALUE EDNT_STRING_TO_F_METHOD = Qnil;
|
21
24
|
|
22
25
|
// returned when EOF - defined as a constant in EDN module
|
23
|
-
VALUE
|
26
|
+
VALUE EDNT_EOF_CONST = Qnil;
|
24
27
|
|
25
28
|
//
|
26
29
|
// wrappers to hook the class w/ the C-api
|
@@ -136,16 +139,16 @@ void Init_edn_turbo(void)
|
|
136
139
|
rb_define_method(rb_cParser, "ext_next", (VALUE(*)(ANYARGS)) &edn::next, 0 );
|
137
140
|
|
138
141
|
// bind ruby methods we'll call - these should be defined in edn_turbo.rb
|
139
|
-
edn::
|
140
|
-
edn::
|
141
|
-
edn::
|
142
|
-
edn::
|
143
|
-
edn::
|
144
|
-
edn::
|
142
|
+
edn::EDNT_MAKE_SYMBOL_METHOD = rb_intern("symbol");
|
143
|
+
edn::EDNT_MAKE_LIST_METHOD = rb_intern("list");
|
144
|
+
edn::EDNT_MAKE_SET_METHOD = rb_intern("set");
|
145
|
+
edn::EDNT_MAKE_BIG_DECIMAL_METHOD = rb_intern("big_decimal");
|
146
|
+
edn::EDNT_TAGGED_ELEM_METHOD = rb_intern("tagged_element");
|
147
|
+
edn::EDNT_EXTENDED_VALUE_METHOD = rb_intern("extend_for_meta");
|
145
148
|
|
146
|
-
|
147
|
-
edn::
|
149
|
+
edn::EDNT_STRING_TO_I_METHOD = rb_intern("to_i");
|
150
|
+
edn::EDNT_STRING_TO_F_METHOD = rb_intern("to_f");
|
148
151
|
|
149
|
-
//
|
150
|
-
|
152
|
+
// so we can return EOF directly
|
153
|
+
edn::EDNT_EOF_CONST = rb_const_get(edn::rb_mEDNT, rb_intern("EOF"));
|
151
154
|
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'edn'
|
2
|
+
|
3
|
+
module EDNT
|
4
|
+
|
5
|
+
# Object returned when there is nothing to return
|
6
|
+
|
7
|
+
NOTHING = EDN::NOTHING
|
8
|
+
|
9
|
+
# Object to return when we hit end of file. Cant be nil or :eof
|
10
|
+
# because either of those could be something in the EDN data.
|
11
|
+
|
12
|
+
EOF = EDN::EOF
|
13
|
+
|
14
|
+
end
|
data/lib/edn_turbo/edn_parser.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
require 'edn'
|
2
|
+
require 'bigdecimal'
|
2
3
|
|
3
4
|
module EDNT
|
4
5
|
|
5
|
-
EOF = Object.new
|
6
|
-
|
7
6
|
class Parser
|
8
7
|
|
9
8
|
# initialize() is defined in the c-side (main.cc)
|
@@ -25,4 +24,8 @@ module EDNT
|
|
25
24
|
|
26
25
|
end
|
27
26
|
|
27
|
+
def self.big_decimal(str)
|
28
|
+
BigDecimal.new(str)
|
29
|
+
end
|
30
|
+
|
28
31
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'edn'
|
2
|
+
|
3
|
+
module EDNT
|
4
|
+
|
5
|
+
# ----------------------------------------------------------------------------
|
6
|
+
# register a tagged element
|
7
|
+
#
|
8
|
+
TAGS = {
|
9
|
+
# built-in tagged elements
|
10
|
+
"inst" => lambda { |*a| DateTime.parse(*a) },
|
11
|
+
"uuid" => lambda { |*a| String.new(*a) }
|
12
|
+
}
|
13
|
+
|
14
|
+
def self.register(tag, func = nil, &block)
|
15
|
+
# don't allow re-registration of built-in tags
|
16
|
+
if tag != "inst" && tag != "uuid"
|
17
|
+
if block_given?
|
18
|
+
func = block
|
19
|
+
end
|
20
|
+
|
21
|
+
if func.nil?
|
22
|
+
func = lambda { |x| x }
|
23
|
+
end
|
24
|
+
|
25
|
+
if func.is_a?(Class)
|
26
|
+
TAGS[tag] = lambda { |*args| func.new(*args) }
|
27
|
+
else
|
28
|
+
TAGS[tag] = func
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.unregister(tag)
|
34
|
+
TAGS[tag] = nil
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.tagged_element(tag, element)
|
38
|
+
func = TAGS[tag]
|
39
|
+
if func
|
40
|
+
func.call(element)
|
41
|
+
else
|
42
|
+
EDN::Type::Unknown.new(tag, element)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'edn'
|
2
|
+
|
3
|
+
module EDNT
|
4
|
+
|
5
|
+
# ============================================================================
|
6
|
+
# emulate EDN::Metadata
|
7
|
+
module Metadata
|
8
|
+
attr_accessor :metadata
|
9
|
+
end
|
10
|
+
|
11
|
+
# ----------------------------------------------------------------------------
|
12
|
+
# bind the given meta to the value
|
13
|
+
#
|
14
|
+
def self.extend_for_meta(value, ext_meta)
|
15
|
+
|
16
|
+
meta = ext_meta
|
17
|
+
|
18
|
+
metadata = meta.reduce({}) do |acc, m|
|
19
|
+
case m
|
20
|
+
when Symbol then acc.merge(m => true)
|
21
|
+
when EDN::Type::Symbol then acc.merge(:tag => m)
|
22
|
+
else acc.merge(m)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
if !metadata.empty?
|
27
|
+
value.extend Metadata
|
28
|
+
value.metadata = metadata
|
29
|
+
end
|
30
|
+
|
31
|
+
value
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
data/lib/edn_turbo/version.rb
CHANGED
data/lib/edn_turbo.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
-
require_relative 'edn_turbo/
|
1
|
+
require_relative 'edn_turbo/constants'
|
2
|
+
require_relative 'edn_turbo/tags'
|
3
|
+
require_relative 'edn_turbo/utils'
|
2
4
|
require_relative 'edn_turbo/version'
|
5
|
+
require_relative 'edn_turbo/edn_parser'
|
3
6
|
require_relative 'edn_turbo/edn_turbo'
|
4
7
|
|
5
|
-
require 'date'
|
6
8
|
require 'set'
|
7
9
|
require 'edn'
|
8
10
|
|
@@ -23,102 +25,18 @@ module EDNT
|
|
23
25
|
end
|
24
26
|
|
25
27
|
# ----------------------------------------------------------------------------
|
26
|
-
#
|
27
|
-
#
|
28
|
-
TAGS = {
|
29
|
-
# built-in tagged elements
|
30
|
-
"inst" => lambda { |*a| DateTime.parse(*a) },
|
31
|
-
"uuid" => lambda { |*a| String.new(*a) }
|
32
|
-
}
|
33
|
-
|
34
|
-
def self.register(tag, func = nil, &block)
|
35
|
-
# don't allow re-registration of built-in tags
|
36
|
-
if tag != "inst" && tag != "uuid"
|
37
|
-
if block_given?
|
38
|
-
func = block
|
39
|
-
end
|
40
|
-
|
41
|
-
if func.nil?
|
42
|
-
func = lambda { |x| x }
|
43
|
-
end
|
44
|
-
|
45
|
-
if func.is_a?(Class)
|
46
|
-
TAGS[tag] = lambda { |*args| func.new(*args) }
|
47
|
-
else
|
48
|
-
TAGS[tag] = func
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def self.unregister(tag)
|
54
|
-
TAGS[tag] = nil
|
55
|
-
end
|
56
|
-
|
57
|
-
def self.tagged_element(tag, element)
|
58
|
-
func = TAGS[tag]
|
59
|
-
if func
|
60
|
-
func.call(element)
|
61
|
-
else
|
62
|
-
EDN::Type::Unknown.new(tag, element)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
# ----------------------------------------------------------------------------
|
67
|
-
# handles creation of a set from an array
|
68
|
-
#
|
69
|
-
def self.make_set(elems)
|
70
|
-
Set.new(elems)
|
71
|
-
end
|
72
|
-
|
73
|
-
# ----------------------------------------------------------------------------
|
74
|
-
# handles creation of an EDN::Type::Symbol
|
28
|
+
# handles creation of various EDN representations
|
75
29
|
#
|
76
|
-
def self.
|
30
|
+
def self.symbol(elem)
|
77
31
|
EDN::Type::Symbol.new(elem)
|
78
32
|
end
|
79
33
|
|
80
|
-
|
81
|
-
|
82
|
-
#
|
83
|
-
def self.string_int_to_bignum(str)
|
84
|
-
str.to_i
|
85
|
-
end
|
86
|
-
|
87
|
-
# ----------------------------------------------------------------------------
|
88
|
-
# to create Big Ints (for now)
|
89
|
-
#
|
90
|
-
def self.string_double_to_bignum(str)
|
91
|
-
str.to_f
|
92
|
-
end
|
93
|
-
|
94
|
-
# ============================================================================
|
95
|
-
# emulate EDN::Metadata
|
96
|
-
module Metadata
|
97
|
-
attr_accessor :metadata
|
34
|
+
def self.list(*elems)
|
35
|
+
EDN::Type::List.new(*elems)
|
98
36
|
end
|
99
37
|
|
100
|
-
|
101
|
-
|
102
|
-
#
|
103
|
-
def self.bind_metadata_to_value(value, ext_meta)
|
104
|
-
|
105
|
-
meta = ext_meta
|
106
|
-
|
107
|
-
metadata = meta.reduce({}) do |acc, m|
|
108
|
-
case m
|
109
|
-
when Symbol then acc.merge(m => true)
|
110
|
-
when EDN::Type::Symbol then acc.merge(:tag => m)
|
111
|
-
else acc.merge(m)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
if !metadata.empty?
|
116
|
-
value.extend Metadata
|
117
|
-
value.metadata = metadata
|
118
|
-
end
|
119
|
-
|
120
|
-
value
|
38
|
+
def self.set(*elems)
|
39
|
+
Set.new(*elems)
|
121
40
|
end
|
122
41
|
|
123
|
-
|
124
42
|
end # EDN namespace
|
data/test/test_output_diff.rb
CHANGED
@@ -12,18 +12,47 @@ class EDNT_Test < Minitest::Test
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def check_file(file, expected_output)
|
15
|
-
|
16
|
-
|
15
|
+
output = nil
|
16
|
+
File.open(file) { |source|
|
17
|
+
input = source.instance_of?(String) ? source : source.read
|
18
|
+
|
19
|
+
# test using parse() first
|
20
|
+
output = @parser.parse(input)
|
21
|
+
assert_equal(expected_output, output)
|
22
|
+
|
23
|
+
# now test setting the source and using read (although one-shot)
|
24
|
+
@parser.set_input(input)
|
25
|
+
output = @parser.read
|
26
|
+
assert_equal(expected_output, output)
|
17
27
|
}
|
28
|
+
output
|
18
29
|
end
|
19
30
|
|
20
|
-
|
31
|
+
# ========================================================================================
|
32
|
+
# tests start here
|
33
|
+
#
|
34
|
+
def test_false
|
35
|
+
check_file('test/false.edn', false)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_tru
|
39
|
+
check_file('test/true.edn', true)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_nil
|
43
|
+
check_file('test/nil.edn', nil)
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_char
|
47
|
+
check_file('test/char.edn', "\f")
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_string
|
51
|
+
check_file('test/string.edn', "abc\"➪\u8226")
|
52
|
+
end
|
21
53
|
|
22
|
-
|
23
|
-
|
24
|
-
assert_equal("a string", @parser.parse('"a string"'))
|
25
|
-
assert_equal(:"namespace.of.some.length/keyword-name", @parser.parse(':namespace.of.some.length/keyword-name'))
|
26
|
-
assert_equal(:'/', @parser.parse(':/'))
|
54
|
+
def test_keyword_with_namespace
|
55
|
+
check_file('test/keyword_with_namespace.edn', :"namespace.of.some.length/keyword-name")
|
27
56
|
end
|
28
57
|
|
29
58
|
def test_number
|
@@ -39,7 +68,7 @@ class EDNT_Test < Minitest::Test
|
|
39
68
|
def test_keyword
|
40
69
|
|
41
70
|
check_file('test/keyword.edn',
|
42
|
-
[:key1, :"key_2/adsd2", :key_3, :"key-4", :"key_5/asd-32_ee"]
|
71
|
+
[:key1, :"key_2/adsd2", :key_3, :"key-4", :"key_5/asd-32_ee", :"#/:a"]
|
43
72
|
)
|
44
73
|
end
|
45
74
|
|
@@ -47,7 +76,7 @@ class EDNT_Test < Minitest::Test
|
|
47
76
|
|
48
77
|
check_file('test/values.edn',
|
49
78
|
[false, true, nil, "this is a test", "this\tis\\only\ta\ttest\rof\"various\nescaped\\values",
|
50
|
-
"c", "\n", "\t",
|
79
|
+
["c", "\n", "\t"],
|
51
80
|
"123➪456®789"]
|
52
81
|
)
|
53
82
|
end
|
@@ -89,8 +118,12 @@ class EDNT_Test < Minitest::Test
|
|
89
118
|
check_file('test/symbol.edn',
|
90
119
|
[
|
91
120
|
EDN::Type::Symbol.new("asymbol"),
|
121
|
+
EDN::Type::Symbol.new(".asymbol"),
|
92
122
|
EDN::Type::Symbol.new("with'_a_'"),
|
93
123
|
EDN::Type::Symbol.new("with.123"),
|
124
|
+
EDN::Type::Symbol.new("-with.123"),
|
125
|
+
EDN::Type::Symbol.new("/"),
|
126
|
+
EDN::Type::Symbol.new(">:FOuy/+"),
|
94
127
|
]
|
95
128
|
)
|
96
129
|
|
@@ -112,13 +145,6 @@ class EDNT_Test < Minitest::Test
|
|
112
145
|
)
|
113
146
|
end
|
114
147
|
|
115
|
-
def test_read
|
116
|
-
|
117
|
-
# check read for using string
|
118
|
-
assert_equal({:a=>1, :b=>2}, @parser.parse('{:a 1 :b 2}'))
|
119
|
-
|
120
|
-
end
|
121
|
-
|
122
148
|
def test_list
|
123
149
|
|
124
150
|
check_file('test/list_1.edn',
|
@@ -143,15 +169,23 @@ class EDNT_Test < Minitest::Test
|
|
143
169
|
|
144
170
|
|
145
171
|
def test_metadata
|
146
|
-
f =
|
147
|
-
assert_equal([98.6, 99.7], f)
|
172
|
+
f = check_file('test/metadata.edn', [98.6, 99.7])
|
148
173
|
assert_equal({:doc=>"This is my vector", :rel=>:temps}, f.metadata)
|
174
|
+
end
|
149
175
|
|
150
|
-
|
151
|
-
|
176
|
+
def test_metadata2
|
177
|
+
f = check_file('test/metadata2.edn', [1, 2])
|
152
178
|
assert_equal({:foo=>true, :tag=>EDN::Type::Symbol.new('String'), :bar=>2}, f.metadata)
|
153
179
|
end
|
154
180
|
|
181
|
+
def test_metadata_in_vector
|
182
|
+
check_file('test/meta_in_vector.edn',
|
183
|
+
[ [ EDN::Type::Symbol.new('c'), :d, true ],
|
184
|
+
DateTime.rfc3339("1390-09-07T21:27:03+00:00")
|
185
|
+
]
|
186
|
+
)
|
187
|
+
end
|
188
|
+
|
155
189
|
#
|
156
190
|
# for testing tagged element #edn_turbo/test_tagged
|
157
191
|
class Tagged
|
@@ -171,7 +205,7 @@ class EDNT_Test < Minitest::Test
|
|
171
205
|
Tagged.new(data).to_s
|
172
206
|
end
|
173
207
|
|
174
|
-
|
208
|
+
check_file('test/tagged_elem.edn', [345, :a])
|
175
209
|
end
|
176
210
|
|
177
211
|
def test_operators
|
@@ -191,10 +225,6 @@ class EDNT_Test < Minitest::Test
|
|
191
225
|
EDN::Type::Symbol.new('='),
|
192
226
|
EDN::Type::Symbol.new('-'),
|
193
227
|
EDN::Type::Symbol.new('+'),
|
194
|
-
# [1, EDN::Type::Symbol.new('/'), 2],
|
195
|
-
# [3, EDN::Type::Symbol.new('/'), 4],
|
196
|
-
[5, EDN::Type::Symbol.new('/'), 6],
|
197
|
-
[7, EDN::Type::Symbol.new('/'), 8]
|
198
228
|
]
|
199
229
|
)
|
200
230
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: edn_turbo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ed Porras
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: edn
|
@@ -75,12 +75,15 @@ files:
|
|
75
75
|
- ext/edn_turbo/extconf.rb
|
76
76
|
- ext/edn_turbo/main.cc
|
77
77
|
- lib/edn_turbo.rb
|
78
|
+
- lib/edn_turbo/constants.rb
|
78
79
|
- lib/edn_turbo/edn_parser.rb
|
80
|
+
- lib/edn_turbo/tags.rb
|
81
|
+
- lib/edn_turbo/utils.rb
|
79
82
|
- lib/edn_turbo/version.rb
|
80
83
|
- test/test_output_diff.rb
|
81
84
|
homepage: http://rubygems.org/gems/edn_turbo
|
82
85
|
licenses:
|
83
|
-
-
|
86
|
+
- MIT
|
84
87
|
metadata: {}
|
85
88
|
post_install_message:
|
86
89
|
rdoc_options: []
|