edn_turbo 0.5.7 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.dir-locals.el +3 -0
- data/.rspec +1 -0
- data/CHANGELOG.md +53 -0
- data/LICENSE +1 -1
- data/README.md +18 -24
- data/Rakefile +22 -27
- data/docker/Dockerfile +40 -0
- data/docker/build +11 -0
- data/docker/common.sh +28 -0
- data/docker/console +11 -0
- data/docker/docker-compose.yml +22 -0
- data/docker/entrypoint +3 -0
- data/docker/make-check +8 -0
- data/docker/run +9 -0
- data/ext/edn_turbo/edn_parser.cc +1206 -1026
- data/ext/edn_turbo/edn_parser.rl +913 -842
- data/ext/edn_turbo/extconf.rb +36 -1
- data/ext/edn_turbo/main.cc +201 -166
- data/ext/edn_turbo/parser.h +105 -76
- data/ext/edn_turbo/parser_def.cc +204 -182
- data/ext/edn_turbo/util.cc +250 -220
- data/ext/edn_turbo/util.h +55 -26
- data/ext/edn_turbo/util_unicode.cc +41 -19
- data/ext/edn_turbo/util_unicode.h +29 -7
- data/lib/edn_turbo.rb +34 -0
- data/lib/edn_turbo/edn_parser.rb +22 -0
- data/lib/edn_turbo/version.rb +24 -2
- data/spec/edn_turbo/edn_parser_spec.rb +419 -0
- data/spec/spec_helper.rb +96 -0
- metadata +65 -15
- data/test/test_output_diff.rb +0 -408
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
4
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
5
|
+
# files.
|
6
|
+
#
|
7
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
8
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
9
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
10
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
11
|
+
# a separate helper file that requires the additional dependencies and performs
|
12
|
+
# the additional setup, and require it from the spec files that actually need
|
13
|
+
# it.
|
14
|
+
#
|
15
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
16
|
+
RSpec.configure do |config|
|
17
|
+
# rspec-expectations config goes here. You can use an alternate
|
18
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
19
|
+
# assertions if you prefer.
|
20
|
+
config.expect_with :rspec do |expectations|
|
21
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
22
|
+
# and `failure_message` of custom matchers include text for helper methods
|
23
|
+
# defined using `chain`, e.g.:
|
24
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
25
|
+
# # => "be bigger than 2 and smaller than 4"
|
26
|
+
# ...rather than:
|
27
|
+
# # => "be bigger than 2"
|
28
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
29
|
+
end
|
30
|
+
|
31
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
32
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
33
|
+
config.mock_with :rspec do |mocks|
|
34
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
35
|
+
# a real object. This is generally recommended, and will default to
|
36
|
+
# `true` in RSpec 4.
|
37
|
+
mocks.verify_partial_doubles = true
|
38
|
+
end
|
39
|
+
|
40
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
41
|
+
# have no way to turn it off -- the option exists only for backwards
|
42
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
43
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
44
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
45
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
46
|
+
|
47
|
+
# This allows you to limit a spec run to individual examples or groups
|
48
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
49
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
50
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
51
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
52
|
+
# config.filter_run_when_matching :focus
|
53
|
+
|
54
|
+
# Allows RSpec to persist some state between runs in order to support
|
55
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
56
|
+
# you configure your source control system to ignore this file.
|
57
|
+
# config.example_status_persistence_file_path = 'spec/examples.txt'
|
58
|
+
|
59
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
60
|
+
# recommended. For more details, see:
|
61
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
62
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
63
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
64
|
+
config.disable_monkey_patching!
|
65
|
+
|
66
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
67
|
+
# be too noisy due to issues in dependencies.
|
68
|
+
config.warnings = true
|
69
|
+
|
70
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
71
|
+
# file, and it's useful to allow more verbose output when running an
|
72
|
+
# individual spec file.
|
73
|
+
if config.files_to_run.one?
|
74
|
+
# Use the documentation formatter for detailed output,
|
75
|
+
# unless a formatter has already been configured
|
76
|
+
# (e.g. via a command-line flag).
|
77
|
+
config.default_formatter = 'doc'
|
78
|
+
end
|
79
|
+
|
80
|
+
# Print the 10 slowest examples and example groups at the
|
81
|
+
# end of the spec run, to help surface which specs are running
|
82
|
+
# particularly slow.
|
83
|
+
# config.profile_examples = 10
|
84
|
+
|
85
|
+
# Run specs in random order to surface order dependencies. If you find an
|
86
|
+
# order dependency and want to debug it, you can fix the order by providing
|
87
|
+
# the seed, which is printed after each run.
|
88
|
+
# --seed 1234
|
89
|
+
# config.order = :random
|
90
|
+
|
91
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
92
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
93
|
+
# test failures related to randomization by passing the same `--seed` value
|
94
|
+
# as the one that triggered the failure.
|
95
|
+
# Kernel.srand config.seed
|
96
|
+
end
|
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.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ed Porras
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: edn
|
@@ -53,34 +53,85 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: pry-byebug
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.7'
|
59
62
|
- - "~>"
|
60
63
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
64
|
+
version: 3.7.0
|
62
65
|
type: :development
|
63
66
|
prerelease: false
|
64
67
|
version_requirements: !ruby/object:Gem::Requirement
|
65
68
|
requirements:
|
69
|
+
- - '='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '3.7'
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 3.7.0
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rspec
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - '='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '3.8'
|
66
82
|
- - "~>"
|
67
83
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
84
|
+
version: 3.8.0
|
85
|
+
type: :development
|
86
|
+
prerelease: false
|
87
|
+
version_requirements: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - '='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '3.8'
|
92
|
+
- - "~>"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 3.8.0
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: rubocop
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '1.9'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - "~>"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '1.9'
|
69
109
|
description: Optimized plugin for parsing EDN files using ragel
|
70
|
-
email:
|
110
|
+
email: github@digressed.net
|
71
111
|
executables:
|
72
112
|
- ppedn
|
73
113
|
extensions:
|
74
114
|
- ext/edn_turbo/extconf.rb
|
75
115
|
extra_rdoc_files: []
|
76
116
|
files:
|
117
|
+
- ".dir-locals.el"
|
77
118
|
- ".gitignore"
|
119
|
+
- ".rspec"
|
120
|
+
- CHANGELOG.md
|
78
121
|
- Gemfile
|
79
122
|
- LICENSE
|
80
123
|
- README.md
|
81
124
|
- Rakefile
|
82
125
|
- bin/ppedn
|
83
126
|
- bin/ppedn-ruby
|
127
|
+
- docker/Dockerfile
|
128
|
+
- docker/build
|
129
|
+
- docker/common.sh
|
130
|
+
- docker/console
|
131
|
+
- docker/docker-compose.yml
|
132
|
+
- docker/entrypoint
|
133
|
+
- docker/make-check
|
134
|
+
- docker/run
|
84
135
|
- ext/edn_turbo/depend
|
85
136
|
- ext/edn_turbo/edn_parser.cc
|
86
137
|
- ext/edn_turbo/edn_parser.rl
|
@@ -95,12 +146,13 @@ files:
|
|
95
146
|
- lib/edn_turbo.rb
|
96
147
|
- lib/edn_turbo/edn_parser.rb
|
97
148
|
- lib/edn_turbo/version.rb
|
98
|
-
-
|
149
|
+
- spec/edn_turbo/edn_parser_spec.rb
|
150
|
+
- spec/spec_helper.rb
|
99
151
|
homepage: http://rubygems.org/gems/edn_turbo
|
100
152
|
licenses:
|
101
153
|
- MIT
|
102
154
|
metadata: {}
|
103
|
-
post_install_message:
|
155
|
+
post_install_message:
|
104
156
|
rdoc_options: []
|
105
157
|
require_paths:
|
106
158
|
- lib
|
@@ -108,17 +160,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
108
160
|
requirements:
|
109
161
|
- - ">="
|
110
162
|
- !ruby/object:Gem::Version
|
111
|
-
version:
|
163
|
+
version: 2.5.0
|
112
164
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
165
|
requirements:
|
114
166
|
- - ">="
|
115
167
|
- !ruby/object:Gem::Version
|
116
168
|
version: '0'
|
117
169
|
requirements: []
|
118
|
-
|
119
|
-
|
120
|
-
signing_key:
|
170
|
+
rubygems_version: 3.2.3
|
171
|
+
signing_key:
|
121
172
|
specification_version: 3
|
122
173
|
summary: Read EDN files
|
123
|
-
test_files:
|
124
|
-
- test/test_output_diff.rb
|
174
|
+
test_files: []
|
data/test/test_output_diff.rb
DELETED
@@ -1,408 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# frozen_string_literal: true
|
4
|
-
|
5
|
-
$LOAD_PATH << File.expand_path(File.dirname(__FILE__) + '/../lib')
|
6
|
-
require 'minitest/autorun'
|
7
|
-
require 'edn_turbo'
|
8
|
-
require 'date'
|
9
|
-
|
10
|
-
class EDNT_Test < Minitest::Test
|
11
|
-
#
|
12
|
-
# helpers
|
13
|
-
def setup
|
14
|
-
@parser = EDNT::Parser.new
|
15
|
-
end
|
16
|
-
|
17
|
-
def check_file(file, expected_output)
|
18
|
-
output = nil
|
19
|
-
File.open(file) do |source|
|
20
|
-
input = source.instance_of?(String) ? source : source.read
|
21
|
-
|
22
|
-
# test using parse() first
|
23
|
-
output = @parser.parse(input)
|
24
|
-
if expected_output.nil?
|
25
|
-
assert_nil(output)
|
26
|
-
else
|
27
|
-
assert_equal(expected_output, output)
|
28
|
-
end
|
29
|
-
|
30
|
-
# now test setting the source and using read (although one-shot)
|
31
|
-
@parser.set_input(input)
|
32
|
-
output = @parser.read
|
33
|
-
if expected_output.nil?
|
34
|
-
assert_nil(output)
|
35
|
-
else
|
36
|
-
assert_equal(expected_output, output)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
# and test passing the IO
|
41
|
-
File.open(file) do |file_io|
|
42
|
-
@parser.set_input(file_io)
|
43
|
-
output = @parser.read
|
44
|
-
if expected_output.nil?
|
45
|
-
assert_nil(output)
|
46
|
-
else
|
47
|
-
assert_equal(expected_output, output)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
output
|
51
|
-
end
|
52
|
-
|
53
|
-
# ============================================================================
|
54
|
-
# tests start here
|
55
|
-
#
|
56
|
-
def test_false
|
57
|
-
check_file('test/false.edn', false)
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_tru
|
61
|
-
check_file('test/true.edn', true)
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_nil
|
65
|
-
check_file('test/nil.edn', nil)
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_char
|
69
|
-
check_file('test/char.edn', "\f")
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_string
|
73
|
-
check_file('test/string.edn', "abc\"➪\u8226")
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_keyword_with_namespace
|
77
|
-
check_file('test/keyword_with_namespace.edn', :"namespace.of.some.length/keyword-name")
|
78
|
-
end
|
79
|
-
|
80
|
-
def test_number
|
81
|
-
check_file('test/number.edn',
|
82
|
-
[0, 0, 5, 12, 232, -98798, 13213, 0.11, 231.312, -2321.0, 11.22, 432,
|
83
|
-
123412341231212121241234,
|
84
|
-
123412341231212121241234,
|
85
|
-
4.54e+44, 4.5e+44])
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_keyword
|
89
|
-
check_file('test/keyword.edn',
|
90
|
-
[:key1, :"key_2/adsd2", :key_3, :"key-4", :"key_5/asd-32_ee", :"#/:a"])
|
91
|
-
end
|
92
|
-
|
93
|
-
def test_values
|
94
|
-
check_file('test/values.edn',
|
95
|
-
[false, true, nil, "this is a test", "this\tis\\only\ta\ttest\rof\"various\nescaped\\values",
|
96
|
-
['c', "\n", "\t"],
|
97
|
-
'123➪456®789'])
|
98
|
-
end
|
99
|
-
|
100
|
-
def test_builtin_tagged_inst
|
101
|
-
check_file('test/inst.edn',
|
102
|
-
[
|
103
|
-
DateTime.rfc3339('1985-04-12T23:20:50.52Z'),
|
104
|
-
DateTime.rfc3339('1996-12-19T16:39:57-08:00'),
|
105
|
-
DateTime.rfc3339('1990-12-31T23:59:60Z'),
|
106
|
-
DateTime.rfc3339('1990-12-31T15:59:60-08:00'),
|
107
|
-
DateTime.rfc3339('1937-01-01T12:00:27.87+00:20')
|
108
|
-
])
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_builtin_tagged_uuid
|
112
|
-
check_file('test/uuid.edn', 'f81d4fae-7dec-11d0-a765-00a0c91e6bf6')
|
113
|
-
end
|
114
|
-
|
115
|
-
def test_sets
|
116
|
-
check_file('test/set.edn',
|
117
|
-
[ Set.new(),
|
118
|
-
Set.new([1, Set.new([:abc])]),
|
119
|
-
Set.new([1]),
|
120
|
-
Set.new([1, 'abc' ]),
|
121
|
-
Set.new([1, 2, 3, [4, 5], 'abc', 23.3])
|
122
|
-
]
|
123
|
-
)
|
124
|
-
end
|
125
|
-
|
126
|
-
def test_symbol
|
127
|
-
check_file('test/symbol.edn',
|
128
|
-
[
|
129
|
-
EDN::Type::Symbol.new('asymbol'),
|
130
|
-
EDN::Type::Symbol.new('.asymbol'),
|
131
|
-
EDN::Type::Symbol.new("with'_a_'"),
|
132
|
-
EDN::Type::Symbol.new('with.123'),
|
133
|
-
EDN::Type::Symbol.new('-with.123'),
|
134
|
-
EDN::Type::Symbol.new('/'),
|
135
|
-
EDN::Type::Symbol.new('>:FOuy/+'),
|
136
|
-
]
|
137
|
-
)
|
138
|
-
end
|
139
|
-
|
140
|
-
def test_unicode
|
141
|
-
check_file('test/unicode.edn',
|
142
|
-
[:text,
|
143
|
-
"Page \u0018, October 2009 TechTIPS",
|
144
|
-
'This should be an unfilled star: ☆']
|
145
|
-
)
|
146
|
-
end
|
147
|
-
|
148
|
-
def test_vector
|
149
|
-
check_file('test/vector_1.edn',
|
150
|
-
[true, true, 34, [true, nil, 'añ', '', :test, [3213.23]]]
|
151
|
-
)
|
152
|
-
end
|
153
|
-
|
154
|
-
def test_list
|
155
|
-
check_file('test/list_1.edn',
|
156
|
-
[22, 3312, 'dss', {:powerpuff=>[:buttercup, :bubbles, :blossom]}]
|
157
|
-
)
|
158
|
-
end
|
159
|
-
|
160
|
-
def test_map
|
161
|
-
check_file('test/map1.edn',
|
162
|
-
{:key_a1=>true,:key_a2=>false,:key_a3=>[1, 2, 3, 'test string', nil, {1=>2}],
|
163
|
-
:key_a4=>{:key_a31=>23, :key_a32=>24.4},'string_key'=>:kval,
|
164
|
-
:embedded=>[true, {:c2g_md5=>'2bbee1cd3045710db6fec432b00d1e0c'}],
|
165
|
-
2=>{:a=>:b}}
|
166
|
-
)
|
167
|
-
|
168
|
-
check_file('test/map2.edn',
|
169
|
-
{int: 1, string: 'hello', char: 'a', array: [0, 1], hash: {key: 'value'}}
|
170
|
-
)
|
171
|
-
end
|
172
|
-
|
173
|
-
|
174
|
-
def test_metadata
|
175
|
-
f = check_file('test/metadata.edn', [98.6, 99.7])
|
176
|
-
assert_equal({:doc=>'This is my vector', rel: :temps}, f.metadata)
|
177
|
-
end
|
178
|
-
|
179
|
-
def test_metadata2
|
180
|
-
f = check_file('test/metadata2.edn', [1, 2])
|
181
|
-
assert_equal({ foo: true, tag: EDN::Type::Symbol.new('String'), bar: 2 }, f.metadata)
|
182
|
-
end
|
183
|
-
|
184
|
-
def test_metadata_in_vector
|
185
|
-
check_file('test/meta_in_vector.edn',
|
186
|
-
[ [ EDN::Type::Symbol.new('c'), :d, true ],
|
187
|
-
DateTime.rfc3339('1390-09-07T21:27:03+00:00')
|
188
|
-
]
|
189
|
-
)
|
190
|
-
end
|
191
|
-
|
192
|
-
#
|
193
|
-
# for testing tagged element #edn_turbo/test_tagged
|
194
|
-
class Tagged
|
195
|
-
def initialize(data)
|
196
|
-
@item = data[:item]
|
197
|
-
@other = data[:other]
|
198
|
-
end
|
199
|
-
|
200
|
-
def to_s
|
201
|
-
[ @item, @other ]
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
def test_tagged_elem
|
206
|
-
|
207
|
-
EDN.register('edn_turbo/test_tagged') do |data|
|
208
|
-
Tagged.new(data).to_s
|
209
|
-
end
|
210
|
-
|
211
|
-
check_file('test/tagged_elem.edn', [345, :a])
|
212
|
-
end
|
213
|
-
|
214
|
-
def test_operators
|
215
|
-
|
216
|
-
check_file('test/operators.edn',
|
217
|
-
[EDN::Type::Symbol.new('/'),
|
218
|
-
EDN::Type::Symbol.new('.'),
|
219
|
-
EDN::Type::Symbol.new('*'),
|
220
|
-
EDN::Type::Symbol.new('!'),
|
221
|
-
EDN::Type::Symbol.new('_'),
|
222
|
-
EDN::Type::Symbol.new('?'),
|
223
|
-
EDN::Type::Symbol.new('$'),
|
224
|
-
EDN::Type::Symbol.new('%'),
|
225
|
-
EDN::Type::Symbol.new('>'),
|
226
|
-
EDN::Type::Symbol.new('<'),
|
227
|
-
EDN::Type::Symbol.new('&'),
|
228
|
-
EDN::Type::Symbol.new('='),
|
229
|
-
EDN::Type::Symbol.new('-'),
|
230
|
-
EDN::Type::Symbol.new('+'),
|
231
|
-
]
|
232
|
-
)
|
233
|
-
|
234
|
-
end
|
235
|
-
|
236
|
-
def test_discard
|
237
|
-
check_file('test/discard.edn', [:a, :b, 42, [:c]])
|
238
|
-
check_file('test/discard2.edn', [:a])
|
239
|
-
check_file('test/discard3.edn', 456)
|
240
|
-
check_file('test/discard4.edn', [1, 2, 3, 4])
|
241
|
-
end
|
242
|
-
|
243
|
-
REF_MAP3_DATA = {:meta=>{:data_format_version=>304,
|
244
|
-
:filename=>'test/colorspan.pdf',
|
245
|
-
:is_ok=>true,
|
246
|
-
:font_engine_ok=>true,
|
247
|
-
:pdf_ver_major=>1,
|
248
|
-
:pdf_ver_minor=>3,
|
249
|
-
:num_pages=>1,
|
250
|
-
:outline=>[],
|
251
|
-
:font_size_list=>[12.0],
|
252
|
-
:lib_versions=>
|
253
|
-
{:edsel=>"0.20.3",:poppler=>"0.29.0",:libpng=>"1.6.16",:openjpeg=>"1.5.0",:boost=>"1.57",:fontconfig=>"2.11.1",:freetype=>"2.5.5",:leptonica=>"1.71"}},
|
254
|
-
:pages=>
|
255
|
-
[{:data_format_version=>304,
|
256
|
-
:pgnum=>1,
|
257
|
-
:is_ok=>true,
|
258
|
-
:width=>612.0,
|
259
|
-
:height=>792.0,
|
260
|
-
:rotation=>0,
|
261
|
-
:has_invisible_text=>false,
|
262
|
-
:text_bounds=>[[72.0, 71.0], [336.11500000000024, 83.0]],
|
263
|
-
:gfx_bounds=>[[0.0, 0.0], [612.0, 792.0]],
|
264
|
-
:bounds=>[[0.0, 0.0], [612.0, 792.0]],
|
265
|
-
:resources=>
|
266
|
-
{:colors=>["#000000", "#ffffff", "#b51a00", "#669c34"],
|
267
|
-
:fonts=>[{:original_name=>"FQRLCA+Helvetica",:family=>"Helvetica",:general_family=>:sans_serif,:type=>:truetype,:embedded=>true,:c2g_md5=>"fca1d2ac4bbb8bb8ca033cd3f24483d6"}],
|
268
|
-
:images=>{},
|
269
|
-
:glyphs=>[]},
|
270
|
-
:text_spans=>
|
271
|
-
[{:bbox=>[[72.0, 71.0], [182.71680000000006, 83.0]],
|
272
|
-
:type=>:span,
|
273
|
-
:text=>"This is a test of the e",
|
274
|
-
:font_idx=>0,
|
275
|
-
:size=>12.0,
|
276
|
-
:color_idx=>0,
|
277
|
-
:x_vector=>
|
278
|
-
[72.0,
|
279
|
-
79.3296,
|
280
|
-
86.00399999999999,
|
281
|
-
88.67039999999999,
|
282
|
-
94.67039999999999,
|
283
|
-
98.00399999999999,
|
284
|
-
100.67039999999999,
|
285
|
-
106.67039999999999,
|
286
|
-
110.00399999999999,
|
287
|
-
116.67839999999998,
|
288
|
-
120.01199999999999,
|
289
|
-
123.34559999999999,
|
290
|
-
130.01999999999998,
|
291
|
-
136.01999999999998,
|
292
|
-
139.3536,
|
293
|
-
142.68720000000002,
|
294
|
-
149.3616,
|
295
|
-
152.69520000000003,
|
296
|
-
156.02880000000005,
|
297
|
-
159.36240000000006,
|
298
|
-
166.03680000000006,
|
299
|
-
172.71120000000005,
|
300
|
-
176.04480000000007],
|
301
|
-
:clip_path=>0},
|
302
|
-
{:bbox=>[[182.7188, 71.0], [216.7316, 83.0]],
|
303
|
-
:type=>:span,
|
304
|
-
:text=>"merge",
|
305
|
-
:font_idx=>0,
|
306
|
-
:size=>12.0,
|
307
|
-
:color_idx=>2,
|
308
|
-
:x_vector=>[182.7188, 192.7148, 199.3892, 203.3852, 210.0596],
|
309
|
-
:clip_path=>0},
|
310
|
-
{:bbox=>[[216.7324, 71.0], [223.4044, 83.0]],
|
311
|
-
:type=>:span,
|
312
|
-
:text=>"n",
|
313
|
-
:font_idx=>0,
|
314
|
-
:size=>12.0,
|
315
|
-
:color_idx=>3,
|
316
|
-
:x_vector=>[216.7324],
|
317
|
-
:clip_path=>0},
|
318
|
-
{:bbox=>[[223.4062, 71.0], [336.11500000000024, 83.0]],
|
319
|
-
:type=>:span,
|
320
|
-
:text=>"cy broadcast system.",
|
321
|
-
:font_idx=>0,
|
322
|
-
:size=>12.0,
|
323
|
-
:color_idx=>0,
|
324
|
-
:x_vector=>
|
325
|
-
[223.4062,
|
326
|
-
229.4062,
|
327
|
-
235.4062,
|
328
|
-
238.73980000000003,
|
329
|
-
245.41420000000002,
|
330
|
-
249.41020000000003,
|
331
|
-
256.0846000000001,
|
332
|
-
262.7590000000001,
|
333
|
-
269.4334000000002,
|
334
|
-
275.4334000000002,
|
335
|
-
282.1078000000002,
|
336
|
-
288.1078000000002,
|
337
|
-
291.4414000000002,
|
338
|
-
294.7750000000002,
|
339
|
-
300.7750000000002,
|
340
|
-
306.7750000000002,
|
341
|
-
312.7750000000002,
|
342
|
-
316.1086000000002,
|
343
|
-
322.78300000000024,
|
344
|
-
332.7790000000002],
|
345
|
-
:clip_path=>0}],
|
346
|
-
:graphics=>
|
347
|
-
[{:type=>:path,
|
348
|
-
:commands=>
|
349
|
-
[[{:move_to=>[0.0, 792.0]},{:line_to=>[612.0, 792.0]},{:line_to=>[612.0, 0.0]},{:line_to=>[0.0, 0.0]},{:line_to=>[0.0, 792.0]},{:close_path=>true}]],
|
350
|
-
:bbox=>[[0.0, 0.0], [612.0, 792.0]],
|
351
|
-
:path_type=>:clip,
|
352
|
-
:id=>0,
|
353
|
-
:attribs=>{}},
|
354
|
-
{:type=>:path,
|
355
|
-
:commands=>
|
356
|
-
[[{:move_to=>[0.0, 792.0]},{:line_to=>[612.0, 792.0]},{:line_to=>[612.0, 0.0]},{:line_to=>[0.0, 0.0]},{:line_to=>[0.0, 792.0]},{:close_path=>true}]],
|
357
|
-
:bbox=>[[0.0, 0.0], [612.0, 792.0]],
|
358
|
-
:path_type=>:fill,
|
359
|
-
:clip_path=>0,
|
360
|
-
:attribs=>{:fill_color_idx=>1}},
|
361
|
-
{:type=>:path,
|
362
|
-
:commands=>
|
363
|
-
[[{:move_to=>[0.0, 792.0]},{:line_to=>[612.0, 792.0]},{:line_to=>[612.0, 0.0]},{:line_to=>[0.0, 0.0]},{:line_to=>[0.0, 792.0]},{:close_path=>true}]],
|
364
|
-
:bbox=>[[0.0, 0.0], [612.0, 792.0]],
|
365
|
-
:path_type=>:fill,
|
366
|
-
:clip_path=>0,
|
367
|
-
:attribs=>{:fill_color_idx=>1}}],
|
368
|
-
:links=>[]}]}
|
369
|
-
|
370
|
-
def test_packard
|
371
|
-
check_file('test/map3.edn', REF_MAP3_DATA)
|
372
|
-
end
|
373
|
-
|
374
|
-
def test_ruby_file_io
|
375
|
-
File.open('test/true.edn', 'r') do |f|
|
376
|
-
# now test setting the source and using read (although one-shot)
|
377
|
-
@parser.set_input(f)
|
378
|
-
output = @parser.read
|
379
|
-
assert_equal(true, output)
|
380
|
-
end
|
381
|
-
end
|
382
|
-
|
383
|
-
def test_ruby_file_io_long
|
384
|
-
File.open('test/map3.edn', 'r') do |f|
|
385
|
-
# now test setting the source and using read (although one-shot)
|
386
|
-
@parser.set_input(f)
|
387
|
-
output = @parser.read
|
388
|
-
assert_equal(REF_MAP3_DATA, output)
|
389
|
-
end
|
390
|
-
end
|
391
|
-
|
392
|
-
def test_ruby_string_io
|
393
|
-
s = StringIO.new('[ true false :alpha :beta 0 ]')
|
394
|
-
|
395
|
-
@parser.set_input(s)
|
396
|
-
output = @parser.read
|
397
|
-
assert_equal([true, false, :alpha, :beta, 0], output)
|
398
|
-
end
|
399
|
-
|
400
|
-
def test_init_arg
|
401
|
-
# test passing IO to constructor
|
402
|
-
File.open('test/map3.edn', 'r') do |f|
|
403
|
-
p = EDNT::Parser.new(f)
|
404
|
-
output = p.read
|
405
|
-
assert_equal(REF_MAP3_DATA, output)
|
406
|
-
end
|
407
|
-
end
|
408
|
-
end
|