oj 1.4.3 → 1.4.4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of oj might be problematic. Click here for more details.

data/README.md CHANGED
@@ -32,9 +32,9 @@ A fast JSON parser and Object marshaller as a Ruby gem.
32
32
 
33
33
  ## <a name="release">Release Notes</a>
34
34
 
35
- ### Release 1.4.3
35
+ ### Release 1.4.4
36
36
 
37
- - Fixed Exception encoding in Windows version.
37
+ - Fixed bug in mimic that missed mimicing json_pure.
38
38
 
39
39
  ## <a name="description">Description</a>
40
40
 
@@ -1,32 +1,3 @@
1
- /* cache8.c
2
- * Copyright (c) 2011, Peter Ohler
3
- * All rights reserved.
4
- *
5
- * Redistribution and use in source and binary forms, with or without
6
- * modification, are permitted provided that the following conditions are met:
7
- *
8
- * - Redistributions of source code must retain the above copyright notice, this
9
- * list of conditions and the following disclaimer.
10
- *
11
- * - Redistributions in binary form must reproduce the above copyright notice,
12
- * this list of conditions and the following disclaimer in the documentation
13
- * and/or other materials provided with the distribution.
14
- *
15
- * - Neither the name of Peter Ohler nor the names of its contributors may be
16
- * used to endorse or promote products derived from this software without
17
- * specific prior written permission.
18
- *
19
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
- */
30
1
 
31
2
  #include <stdlib.h>
32
3
  #include <errno.h>
@@ -34,33 +5,34 @@
34
5
  #include <string.h>
35
6
  #include <stdarg.h>
36
7
 
8
+ #include "ruby.h"
37
9
  #include "cache8.h"
38
10
 
39
- #define BITS 4
40
- #define MASK 0x000000000000000F
41
- #define SLOT_CNT 16
42
- #define DEPTH 16
11
+ #define BITS 4
12
+ #define MASK 0x000000000000000FULL
13
+ #define SLOT_CNT 16
14
+ #define DEPTH 16
15
+
16
+ typedef union {
17
+ struct _Cache8 *child;
18
+ slot_t value;
19
+ } Bucket;
43
20
 
44
21
  struct _Cache8 {
45
- union {
46
- struct _Cache8 *slots[SLOT_CNT];
47
- slot_t values[SLOT_CNT];
48
- };
22
+ Bucket buckets[SLOT_CNT];
49
23
  };
50
24
 
51
25
  static void cache8_delete(Cache8 cache, int depth);
52
- static void slot_print(Cache8 cache, VALUE key, unsigned int depth);
26
+ static void slot_print(Cache8 cache, sid_t key, unsigned int depth);
53
27
 
54
28
  void
55
29
  oj_cache8_new(Cache8 *cache) {
56
- Cache8 *cp;
30
+ Bucket *b;
57
31
  int i;
58
32
 
59
- if (0 == (*cache = ALLOC(struct _Cache8))) {
60
- rb_raise(rb_eNoMemError, "not enough memory\n");
61
- }
62
- for (i = SLOT_CNT, cp = (*cache)->slots; 0 < i; i--, cp++) {
63
- *cp = 0;
33
+ *cache = ALLOC(struct _Cache8);
34
+ for (i = SLOT_CNT, b = (*cache)->buckets; 0 < i; i--, b++) {
35
+ b->value = 0;
64
36
  }
65
37
  }
66
38
 
@@ -71,13 +43,13 @@ oj_cache8_delete(Cache8 cache) {
71
43
 
72
44
  static void
73
45
  cache8_delete(Cache8 cache, int depth) {
74
- Cache8 *cp;
46
+ Bucket *b;
75
47
  unsigned int i;
76
48
 
77
- for (i = 0, cp = cache->slots; i < SLOT_CNT; i++, cp++) {
78
- if (0 != *cp) {
49
+ for (i = 0, b = cache->buckets; i < SLOT_CNT; i++, b++) {
50
+ if (0 != b->child) {
79
51
  if (DEPTH - 1 != depth) {
80
- cache8_delete(*cp, depth + 1);
52
+ cache8_delete(b->child, depth + 1);
81
53
  }
82
54
  }
83
55
  }
@@ -85,44 +57,46 @@ cache8_delete(Cache8 cache, int depth) {
85
57
  }
86
58
 
87
59
  slot_t
88
- oj_cache8_get(Cache8 cache, VALUE key, slot_t **slot) {
89
- Cache8 *cp;
60
+ oj_cache8_get(Cache8 cache, sid_t key, slot_t **slot) {
61
+ Bucket *b;
90
62
  int i;
91
- VALUE k;
63
+ sid_t k8 = (sid_t)key;
64
+ sid_t k;
92
65
 
93
66
  for (i = 64 - BITS; 0 < i; i -= BITS) {
94
- k = (key >> i) & MASK;
95
- cp = cache->slots + k;
96
- if (0 == *cp) {
97
- oj_cache8_new(cp);
67
+ k = (k8 >> i) & MASK;
68
+ b = cache->buckets + k;
69
+ if (0 == b->child) {
70
+ oj_cache8_new(&b->child);
98
71
  }
99
- cache = *cp;
72
+ cache = b->child;
100
73
  }
101
- *slot = cache->values + (key & MASK);
74
+ *slot = &(cache->buckets + (k8 & MASK))->value;
102
75
 
103
76
  return **slot;
104
77
  }
105
78
 
106
79
  void
107
80
  oj_cache8_print(Cache8 cache) {
108
- //printf("-------------------------------------------\n");
81
+ /*printf("-------------------------------------------\n"); */
109
82
  slot_print(cache, 0, 0);
110
83
  }
111
84
 
112
85
  static void
113
- slot_print(Cache8 c, VALUE key, unsigned int depth) {
114
- Cache8 *cp;
86
+ slot_print(Cache8 c, sid_t key, unsigned int depth) {
87
+ Bucket *b;
115
88
  unsigned int i;
116
- unsigned long k;
89
+ sid_t k8 = (sid_t)key;
90
+ sid_t k;
117
91
 
118
- for (i = 0, cp = c->slots; i < SLOT_CNT; i++, cp++) {
119
- if (0 != *cp) {
120
- k = (key << BITS) | i;
121
- //printf("*** key: 0x%016lx depth: %u i: %u\n", k, depth, i);
92
+ for (i = 0, b = c->buckets; i < SLOT_CNT; i++, b++) {
93
+ if (0 != b->child) {
94
+ k = (k8 << BITS) | i;
95
+ /*printf("*** key: 0x%016llx depth: %u i: %u\n", k, depth, i); */
122
96
  if (DEPTH - 1 == depth) {
123
- printf("0x%016lx: %4lu\n", k, (unsigned long)*cp);
97
+ printf("0x%016llx: %4llu\n", k, b->value);
124
98
  } else {
125
- slot_print(*cp, k, depth + 1);
99
+ slot_print(b->child, k, depth + 1);
126
100
  }
127
101
  }
128
102
  }
@@ -31,18 +31,18 @@
31
31
  #ifndef __OJ_CACHE8_H__
32
32
  #define __OJ_CACHE8_H__
33
33
 
34
- #define RSTRING_NOT_MODIFIED
35
-
36
34
  #include "ruby.h"
35
+ #include "stdint.h"
37
36
 
38
- typedef struct _Cache8 *Cache8;
39
- typedef unsigned long slot_t;
37
+ typedef struct _Cache8 *Cache8;
38
+ typedef uint64_t slot_t;
39
+ typedef uint64_t sid_t;
40
40
 
41
- extern void oj_cache8_new(Cache8 *cache);
42
- extern void oj_cache8_delete(Cache8 cache);
41
+ extern void oj_cache8_new(Cache8 *cache);
42
+ extern void oj_cache8_delete(Cache8 cache);
43
43
 
44
- extern slot_t oj_cache8_get(Cache8 cache, VALUE key, slot_t **slot);
44
+ extern slot_t oj_cache8_get(Cache8 cache, sid_t key, slot_t **slot);
45
45
 
46
- extern void oj_cache8_print(Cache8 cache);
46
+ extern void oj_cache8_print(Cache8 cache);
47
47
 
48
48
  #endif /* __OJ_CACHE8_H__ */
@@ -66,7 +66,7 @@ typedef struct _ParseInfo {
66
66
  char *str; /* buffer being read from */
67
67
  char *s; /* current position in buffer */
68
68
  Doc doc;
69
- uint64_t stack_min;
69
+ void *stack_min;
70
70
  } *ParseInfo;
71
71
 
72
72
  static void leaf_init(Leaf leaf, int type);
@@ -481,11 +481,7 @@ static Leaf
481
481
  read_next(ParseInfo pi) {
482
482
  Leaf leaf = 0;
483
483
 
484
- #if IS_WINDOWS
485
- if ((uint64_t)(uint32_t)&leaf < pi->stack_min) {
486
- #else
487
- if ((uint64_t)&leaf < pi->stack_min) {
488
- #endif
484
+ if ((void*)&leaf < pi->stack_min) {
489
485
  rb_raise(rb_eSysStackError, "JSON is too deeply nested");
490
486
  }
491
487
  next_non_white(pi); // skip white space
@@ -849,13 +845,13 @@ parse_json(VALUE clas, char *json, int given, int allocated) {
849
845
  doc_init(doc);
850
846
  pi.doc = doc;
851
847
  #if IS_WINDOWS
852
- pi.stack_min = (uint64_t)(uint32_t)&pi - (512 * 1024); // assume a 1M stack and give half to ruby
848
+ pi.stack_min = (void*)((char*)&pi - (512 * 1024)); // assume a 1M stack and give half to ruby
853
849
  #else
854
850
  {
855
851
  struct rlimit lim;
856
852
 
857
853
  if (0 == getrlimit(RLIMIT_STACK, &lim)) {
858
- pi.stack_min = (uint64_t)&pi - (lim.rlim_cur / 4 * 3); // let 3/4ths of the stack be used only
854
+ pi.stack_min = (void*)((char*)&lim - (lim.rlim_cur / 4 * 3)); // let 3/4ths of the stack be used only
859
855
  } else {
860
856
  pi.stack_min = 0; // indicates not to check stack limit
861
857
  }
@@ -62,7 +62,7 @@ typedef struct _ParseInfo {
62
62
  char *s; /* current position in buffer */
63
63
  CircArray circ_array;
64
64
  Options options;
65
- uint64_t stack_min;
65
+ void *stack_min;
66
66
  } *ParseInfo;
67
67
 
68
68
  static CircArray circ_array_new(void);
@@ -323,11 +323,7 @@ static VALUE
323
323
  read_next(ParseInfo pi, int hint) {
324
324
  VALUE obj;
325
325
 
326
- #if IS_WINDOWS
327
- if ((uint64_t)(uint32_t)&obj < pi->stack_min) {
328
- #else
329
- if ((uint64_t)&obj < pi->stack_min) {
330
- #endif
326
+ if ((void*)&obj < pi->stack_min) {
331
327
  rb_raise(rb_eSysStackError, "JSON is too deeply nested");
332
328
  }
333
329
  next_non_white(pi); // skip white space
@@ -1022,13 +1018,13 @@ oj_parse(char *json, Options options) {
1022
1018
  }
1023
1019
  pi.options = options;
1024
1020
  #if IS_WINDOWS
1025
- pi.stack_min = (uint64_t)(uint32_t)&obj - (512 * 1024); // assume a 1M stack and give half to ruby
1021
+ pi.stack_min = (void*)((char*)&obj - (512 * 1024)); // assume a 1M stack and give half to ruby
1026
1022
  #else
1027
1023
  {
1028
1024
  struct rlimit lim;
1029
1025
 
1030
1026
  if (0 == getrlimit(RLIMIT_STACK, &lim)) {
1031
- pi.stack_min = (uint64_t)&obj - (lim.rlim_cur / 4 * 3); // let 3/4ths of the stack be used only
1027
+ pi.stack_min = (void*)((char*)&obj - (lim.rlim_cur / 4 * 3)); // let 3/4ths of the stack be used only
1032
1028
  } else {
1033
1029
  pi.stack_min = 0; // indicates not to check stack limit
1034
1030
  }
@@ -4,7 +4,7 @@ module Oj
4
4
  def self.mimic_loaded()
5
5
  gems_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__))))
6
6
  Dir.foreach(gems_dir) do |gem|
7
- next unless gem.start_with?('json-')
7
+ next unless (gem.start_with?('json-') || gem.start_with?('json_pure'))
8
8
  $LOADED_FEATURES << File.join(gems_dir, gem, 'lib', 'json.rb')
9
9
  end
10
10
  end
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Oj
3
3
  # Current version of the module.
4
- VERSION = '1.4.3'
4
+ VERSION = '1.4.4'
5
5
  end
@@ -1,6 +1,12 @@
1
- #!/usr/bin/env ruby -wW1
1
+ #!/usr/bin/env ruby
2
2
  # encoding: UTF-8
3
3
 
4
+ # Ubuntu does not accept arguments to ruby when called using env. To get warnings to show up the -w options is
5
+ # required. That can be set in the RUBYOPT environment variable.
6
+ # export RUBYOPT=-w
7
+
8
+ $VERBOSE = true
9
+
4
10
  $: << File.join(File.dirname(__FILE__), "../lib")
5
11
  $: << File.join(File.dirname(__FILE__), "../ext")
6
12
 
@@ -145,7 +151,7 @@ class DocTest < ::Test::Unit::TestCase
145
151
  end
146
152
  begin
147
153
  doc.move('/array/x')
148
- rescue Exception => e
154
+ rescue Exception
149
155
  assert_equal('/', doc.where?)
150
156
  assert(true)
151
157
  end
@@ -324,7 +330,7 @@ class DocTest < ::Test::Unit::TestCase
324
330
  doc.close()
325
331
  begin
326
332
  doc.home()
327
- rescue Exception => e
333
+ rescue Exception
328
334
  assert(true)
329
335
  end
330
336
  end
@@ -343,7 +349,7 @@ class DocTest < ::Test::Unit::TestCase
343
349
  doc.close()
344
350
  begin
345
351
  doc.home()
346
- rescue Exception => e
352
+ rescue Exception
347
353
  assert(true)
348
354
  end
349
355
  end
@@ -1,6 +1,12 @@
1
- #!/usr/bin/env ruby -wW1
1
+ #!/usr/bin/env ruby
2
2
  # encoding: UTF-8
3
3
 
4
+ # Ubuntu does not accept arguments to ruby when called using env. To get warnings to show up the -w options is
5
+ # required. That can be set in the RUBYOPT environment variable.
6
+ # export RUBYOPT=-w
7
+
8
+ $VERBOSE = true
9
+
4
10
  $: << File.join(File.dirname(__FILE__), "../lib")
5
11
  $: << File.join(File.dirname(__FILE__), "../ext")
6
12
 
@@ -1,6 +1,12 @@
1
- #!/usr/bin/env ruby -wW1
1
+ #!/usr/bin/env ruby
2
2
  # encoding: UTF-8
3
3
 
4
+ # Ubuntu does not accept arguments to ruby when called using env. To get warnings to show up the -w options is
5
+ # required. That can be set in the RUBYOPT environment variable.
6
+ # export RUBYOPT=-w
7
+
8
+ $VERBOSE = true
9
+
4
10
  $: << File.join(File.dirname(__FILE__), "../lib")
5
11
  $: << File.join(File.dirname(__FILE__), "../ext")
6
12
 
@@ -213,9 +219,9 @@ class Juice < ::Test::Unit::TestCase
213
219
  # Symbol
214
220
  def test_symbol_strict
215
221
  begin
216
- json = Oj.dump(:abc, :mode => :strict)
222
+ Oj.dump(:abc, :mode => :strict)
217
223
  assert(false)
218
- rescue Exception => e
224
+ rescue Exception
219
225
  assert(true)
220
226
  end
221
227
  end
@@ -238,9 +244,9 @@ class Juice < ::Test::Unit::TestCase
238
244
  def test_time_strict
239
245
  t = Time.local(2012, 1, 5, 23, 58, 7)
240
246
  begin
241
- json = Oj.dump(t, :mode => :strict)
247
+ Oj.dump(t, :mode => :strict)
242
248
  assert(false)
243
- rescue Exception => e
249
+ rescue Exception
244
250
  assert(true)
245
251
  end
246
252
  end
@@ -266,7 +272,7 @@ class Juice < ::Test::Unit::TestCase
266
272
  t = Time.new(2012, 1, 5, 23, 58, 7.123456000, 34200)
267
273
  json = Oj.dump(t, :mode => :compat, :time_format => :xmlschema)
268
274
  assert_equal(%{"2012-01-05T23:58:07.123456000+09:30"}, json)
269
- rescue Exception => e
275
+ rescue Exception
270
276
  # some Rubies (1.8.7) do not allow the timezome to be set
271
277
  t = Time.local(2012, 1, 5, 23, 58, 7, 123456)
272
278
  json = Oj.dump(t, :mode => :compat, :time_format => :xmlschema)
@@ -285,7 +291,7 @@ class Juice < ::Test::Unit::TestCase
285
291
  t = Time.new(2012, 1, 5, 23, 58, 7.0, 34200)
286
292
  json = Oj.dump(t, :mode => :compat, :time_format => :xmlschema)
287
293
  assert_equal(%{"2012-01-05T23:58:07+09:30"}, json)
288
- rescue Exception => e
294
+ rescue Exception
289
295
  # some Rubies (1.8.7) do not allow the timezome to be set
290
296
  t = Time.local(2012, 1, 5, 23, 58, 7, 0)
291
297
  json = Oj.dump(t, :mode => :compat, :time_format => :xmlschema)
@@ -304,11 +310,11 @@ class Juice < ::Test::Unit::TestCase
304
310
  t = Time.new(2012, 1, 5, 23, 58, 7.0, 0)
305
311
  json = Oj.dump(t, :mode => :compat, :time_format => :xmlschema)
306
312
  assert_equal(%{"2012-01-05T23:58:07Z"}, json)
307
- rescue Exception => e
313
+ rescue Exception
308
314
  # some Rubies (1.8.7) do not allow the timezome to be set
309
315
  t = Time.utc(2012, 1, 5, 23, 58, 7, 0)
310
316
  json = Oj.dump(t, :mode => :compat, :time_format => :xmlschema)
311
- tz = t.utc_offset
317
+ #tz = t.utc_offset
312
318
  assert_equal(%{"2012-01-05T23:58:07Z"}, json)
313
319
  end
314
320
  end
@@ -321,9 +327,9 @@ class Juice < ::Test::Unit::TestCase
321
327
  # Class
322
328
  def test_class_strict
323
329
  begin
324
- json = Oj.dump(Juice, :mode => :strict)
330
+ Oj.dump(Juice, :mode => :strict)
325
331
  assert(false)
326
- rescue Exception => e
332
+ rescue Exception
327
333
  assert(true)
328
334
  end
329
335
  end
@@ -349,23 +355,23 @@ class Juice < ::Test::Unit::TestCase
349
355
  end
350
356
  def test_non_str_hash_strict
351
357
  begin
352
- json = Oj.dump({ 1 => true, 0 => false }, :mode => :strict)
358
+ Oj.dump({ 1 => true, 0 => false }, :mode => :strict)
353
359
  assert(false)
354
- rescue Exception => e
360
+ rescue Exception
355
361
  assert(true)
356
362
  end
357
363
  end
358
364
  def test_non_str_hash_null
359
365
  begin
360
- json = Oj.dump({ 1 => true, 0 => false }, :mode => :null)
366
+ Oj.dump({ 1 => true, 0 => false }, :mode => :null)
361
367
  assert(false)
362
- rescue Exception => e
368
+ rescue Exception
363
369
  assert(true)
364
370
  end
365
371
  end
366
372
  def test_non_str_hash_compat
367
373
  begin
368
- json = Oj.dump({ 1 => true, 0 => false }, :mode => :compat)
374
+ Oj.dump({ 1 => true, 0 => false }, :mode => :compat)
369
375
  assert(false)
370
376
  rescue Exception => e
371
377
  assert(e.message.include?('Fixnum'))
@@ -393,9 +399,9 @@ class Juice < ::Test::Unit::TestCase
393
399
  def test_json_object_strict
394
400
  obj = Jeez.new(true, 58)
395
401
  begin
396
- json = Oj.dump(obj, :mode => :strict)
402
+ Oj.dump(obj, :mode => :strict)
397
403
  assert(false)
398
- rescue Exception => e
404
+ rescue Exception
399
405
  assert(true)
400
406
  end
401
407
  end
@@ -439,9 +445,9 @@ class Juice < ::Test::Unit::TestCase
439
445
  def test_to_hash_object_strict
440
446
  obj = Jazz.new(true, 58)
441
447
  begin
442
- json = Oj.dump(obj, :mode => :strict)
448
+ Oj.dump(obj, :mode => :strict)
443
449
  assert(false)
444
- rescue Exception => e
450
+ rescue Exception
445
451
  assert(true)
446
452
  end
447
453
  end
@@ -475,9 +481,9 @@ class Juice < ::Test::Unit::TestCase
475
481
  def test_as_json_object_strict
476
482
  obj = Orange.new(true, 58)
477
483
  begin
478
- json = Oj.dump(obj, :mode => :strict)
484
+ Oj.dump(obj, :mode => :strict)
479
485
  assert(false)
480
- rescue Exception => e
486
+ rescue Exception
481
487
  assert(true)
482
488
  end
483
489
  end
@@ -492,6 +498,7 @@ class Juice < ::Test::Unit::TestCase
492
498
  Oj.default_options = { :mode => :compat }
493
499
  obj = Orange.new(true, 58)
494
500
  json = Oj.dump(obj, :indent => 2)
501
+ assert(!json.nil?)
495
502
  =begin
496
503
  assert_equal(%{{
497
504
  "json_class":"Orange",
@@ -527,9 +534,9 @@ class Juice < ::Test::Unit::TestCase
527
534
  def test_object_strict
528
535
  obj = Jam.new(true, 58)
529
536
  begin
530
- json = Oj.dump(obj, :mode => :strict)
537
+ Oj.dump(obj, :mode => :strict)
531
538
  assert(false)
532
- rescue Exception => e
539
+ rescue Exception
533
540
  assert(true)
534
541
  end
535
542
  end
@@ -591,9 +598,9 @@ class Juice < ::Test::Unit::TestCase
591
598
  # Range
592
599
  def test_range_strict
593
600
  begin
594
- json = Oj.dump(1..7, :mode => :strict)
601
+ Oj.dump(1..7, :mode => :strict)
595
602
  assert(false)
596
- rescue Exception => e
603
+ rescue Exception
597
604
  assert(true)
598
605
  end
599
606
  end
@@ -677,9 +684,9 @@ class Juice < ::Test::Unit::TestCase
677
684
  # Date
678
685
  def test_date_strict
679
686
  begin
680
- json = Oj.dump(Date.new(2012, 6, 19), :mode => :strict)
687
+ Oj.dump(Date.new(2012, 6, 19), :mode => :strict)
681
688
  assert(false)
682
- rescue Exception => e
689
+ rescue Exception
683
690
  assert(true)
684
691
  end
685
692
  end
@@ -706,9 +713,9 @@ class Juice < ::Test::Unit::TestCase
706
713
  # DateTime
707
714
  def test_datetime_strict
708
715
  begin
709
- json = Oj.dump(DateTime.new(2012, 6, 19, 20, 19, 27), :mode => :strict)
716
+ Oj.dump(DateTime.new(2012, 6, 19, 20, 19, 27), :mode => :strict)
710
717
  assert(false)
711
- rescue Exception => e
718
+ rescue Exception
712
719
  assert(true)
713
720
  end
714
721
  end
@@ -771,7 +778,7 @@ class Juice < ::Test::Unit::TestCase
771
778
  json = Oj.dump(h, :mode => :object, :indent => 2, :circular => true)
772
779
  ha = Oj.load(json, :mode => :strict)
773
780
  assert_equal({'^i' => 1, 'a' => 7, 'b' => '^r1'}, ha)
774
- h2 = Oj.load(json, :mode => :object, :circular => true)
781
+ Oj.load(json, :mode => :object, :circular => true)
775
782
  assert_equal(h['b'].__id__, h.__id__)
776
783
  end
777
784
 
@@ -794,11 +801,24 @@ class Juice < ::Test::Unit::TestCase
794
801
  json = Oj.dump(obj, :mode => :object, :indent => 2, :circular => true)
795
802
  ha = Oj.load(json, :mode => :strict)
796
803
  assert_equal({'^o' => 'Jam', '^i' => 1, 'x' => { '^i' => 2, 'a' => 7, 'b' => '^r1' }, 'y' => 58 }, ha)
797
- obj2 = Oj.load(json, :mode => :object, :circular => true)
804
+ Oj.load(json, :mode => :object, :circular => true)
798
805
  assert_equal(obj.x.__id__, h.__id__)
799
806
  assert_equal(h['b'].__id__, obj.__id__)
800
807
  end
801
808
 
809
+ # Stream Deeply Nested
810
+ def test_deep_nest
811
+ unless 'jruby' == RUBY_DESCRIPTION.split(' ')[0]
812
+ begin
813
+ n = 100000
814
+ Oj.load('[' * n + ']' * n)
815
+ assert(false)
816
+ rescue Exception => e
817
+ assert(e.class == SystemStackError)
818
+ end
819
+ end
820
+ end
821
+
802
822
  # Stream IO
803
823
  def test_io_string
804
824
  json = %{{
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oj
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.3
4
+ version: 1.4.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-19 00:00:00.000000000 Z
12
+ date: 2012-11-07 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ! 'The fastest JSON parser and object serializer. '
15
15
  email: peter@ohler.com