Apply pretty print tool.

Apply on each class in test suite and library.
This commit is contained in:
Conaclos
2014-07-04 17:59:05 +02:00
parent 361773101e
commit 20e704604a
33 changed files with 2005 additions and 1983 deletions

View File

@@ -26,7 +26,9 @@ feature -- Access
create template_content.make_empty
l_file.read_stream (l_file.count)
l_last_string := l_file.last_string
check l_last_string /= Void end -- implied by postcondition of `l_file.read_stream'
check
l_last_string /= Void
end -- implied by postcondition of `l_file.read_stream'
template_content.append (l_last_string.string)
Result := template_content
l_file.close

View File

@@ -1,8 +1,5 @@
note
description:
"JSON Iterator"
description: "JSON Iterator"
pattern: "Iterator visitor"
author: "Jocelyn Fiat"
license: "MIT (see http://www.opensource.org/licenses/mit-license.php)"
@@ -13,6 +10,7 @@ deferred class
JSON_ITERATOR
inherit
JSON_VISITOR
feature -- Visitor Pattern

View File

@@ -6,11 +6,11 @@ class
JSON_PRETTY_STRING_VISITOR
inherit
JSON_VISITOR
create
make,
make_custom
make, make_custom
feature -- Initialization
@@ -26,7 +26,6 @@ feature -- Initialization
output := a_output
create indentation.make_empty
indentation_step := "%T"
object_count_inlining := a_object_count_inlining
array_count_inlining := a_array_count_inlining
end
@@ -60,6 +59,7 @@ feature -- Access
end
object_count_inlining: INTEGER
array_count_inlining: INTEGER
feature -- Visitor Pattern
@@ -82,10 +82,7 @@ feature -- Visitor Pattern
until
l_json_array.off
loop
if
line_number > l_line or
l_multiple_lines
then
if line_number > l_line or l_multiple_lines then
new_line
end
value := l_json_array.item
@@ -96,10 +93,7 @@ feature -- Visitor Pattern
end
end
exdent
if
line_number > l_line or
l_json_array.count >= array_count_inlining
then
if line_number > l_line or l_json_array.count >= array_count_inlining then
new_line
end
output.append ("]")
@@ -140,10 +134,7 @@ feature -- Visitor Pattern
until
l_pairs.off
loop
if
line_number > l_line or
l_multiple_lines
then
if line_number > l_line or l_multiple_lines then
new_line
end
l_pairs.key_for_iteration.accept (Current)
@@ -155,10 +146,7 @@ feature -- Visitor Pattern
end
end
exdent
if
line_number > l_line or
l_pairs.count >= object_count_inlining
then
if line_number > l_line or l_pairs.count >= object_count_inlining then
new_line
end
output.append ("}")

View File

@@ -1,8 +1,5 @@
note
description:
"JSON Visitor"
description: "JSON Visitor"
pattern: "Visitor"
author: "Javier Velilla"
license: "MIT (see http://www.opensource.org/licenses/mit-license.php)"

View File

@@ -8,9 +8,11 @@ class
PRINT_JSON_VISITOR
inherit
JSON_VISITOR
create make
create
make
feature -- Initialization

View File

@@ -5,9 +5,11 @@ note
revision: "$Revision$"
file: "$HeadURL: $"
class JSON_ARRAYED_LIST_CONVERTER
class
JSON_ARRAYED_LIST_CONVERTER
inherit
JSON_LIST_CONVERTER
redefine
object

View File

@@ -5,9 +5,11 @@ note
revision: "$Revision$"
file: "$HeadURL: $"
deferred class JSON_CONVERTER
deferred class
JSON_CONVERTER
inherit
SHARED_EJSON
feature -- Access

View File

@@ -5,9 +5,11 @@ note
revision: "$Revision: 94128 $"
file: "$HeadURL: $"
class JSON_HASH_TABLE_CONVERTER
class
JSON_HASH_TABLE_CONVERTER
inherit
JSON_CONVERTER
create
@@ -36,10 +38,14 @@ feature -- Conversion
if attached {HASHABLE} json.object (ic.key, Void) as h then
Result.put (l_object, h)
else
check key_is_hashable: False end
check
key_is_hashable: False
end
end
else
check object_attached: False end
check
object_attached: False
end
end
end
end

View File

@@ -5,9 +5,11 @@ note
revision: "$Revision$"
file: "$HeadURL: $"
class JSON_LINKED_LIST_CONVERTER
class
JSON_LINKED_LIST_CONVERTER
inherit
JSON_LIST_CONVERTER
redefine
object

View File

@@ -5,9 +5,11 @@ note
revision: "$Revision$"
file: "$HeadURL: $"
deferred class JSON_LIST_CONVERTER
deferred class
JSON_LIST_CONVERTER
inherit
JSON_CONVERTER
feature {NONE} -- Initialization

View File

@@ -5,9 +5,11 @@ note
revision: "$Revision$"
file: "$HeadURL: $"
class EJSON
class
EJSON
inherit
EXCEPTIONS
feature -- Access
@@ -56,7 +58,9 @@ feature -- Access
if attached value (a @ i) as v then
ja.add (v)
else
check value_attached: False end
check
value_attached: False
end
end
i := i + 1
end
@@ -65,13 +69,11 @@ feature -- Access
create {JSON_STRING} Result.make_json (c8.out)
elseif attached {CHARACTER_32} an_object as c32 then
create {JSON_STRING} Result.make_json (c32.out)
elseif attached {STRING_8} an_object as s8 then
create {JSON_STRING} Result.make_json (s8)
elseif attached {STRING_32} an_object as s32 then
create {JSON_STRING} Result.make_json_from_string_32 (s32)
end
if Result = Void then
-- Now check the converters
if an_object /= Void and then attached converter_for (an_object) as jc then

View File

@@ -7,7 +7,6 @@ note
[]
[elements]
]"
author: "Javier Velilla"
date: "2008/08/24"
revision: "Revision 0.1"
@@ -16,6 +15,7 @@ class
JSON_ARRAY
inherit
JSON_VALUE
ITERABLE [JSON_VALUE]
@@ -103,8 +103,7 @@ feature -- Change Element
do
values.put_front (v)
ensure
has_new_value: old values.count + 1 = values.count and
values.first = v
has_new_value: old values.count + 1 = values.count and values.first = v
end
add, extend (v: JSON_VALUE)
@@ -113,8 +112,7 @@ feature -- Change Element
do
values.extend (v)
ensure
has_new_value: old values.count + 1 = values.count and
values.has (v)
has_new_value: old values.count + 1 = values.count and values.has (v)
end
prune_all (v: JSON_VALUE)

View File

@@ -8,6 +8,7 @@ class
JSON_BOOLEAN
inherit
JSON_VALUE
create

View File

@@ -8,6 +8,7 @@ class
JSON_NULL
inherit
JSON_VALUE
feature --Access

View File

@@ -1,5 +1,4 @@
note
description: "JSON Numbers, octal and hexadecimal formats are not used."
author: "Javier Velilla"
date: "2008/08/24"
@@ -10,15 +9,14 @@ class
JSON_NUMBER
inherit
JSON_VALUE
redefine
is_equal
end
create
make_integer,
make_natural,
make_real
make_integer, make_natural, make_real
feature {NONE} -- initialization
@@ -88,7 +86,9 @@ feature -- Status report
feature -- Implementation
INTEGER_TYPE: INTEGER = 1
DOUBLE_TYPE: INTEGER = 2
NATURAL_TYPE: INTEGER = 3
numeric_type: INTEGER

View File

@@ -1,5 +1,4 @@
note
description: "[
An JSON_OBJECT represent an object in JSON.
An object is an unordered set of name/value pairs
@@ -9,7 +8,6 @@ note
object
{}
{"key": "value"}
]"
author: "Javier Velilla"
date: "2008/08/24"
@@ -20,6 +18,7 @@ class
JSON_OBJECT
inherit
JSON_VALUE
TABLE_ITERABLE [JSON_VALUE, JSON_STRING]
@@ -66,7 +65,6 @@ feature -- Change Element
put (l_value, key)
end
put_integer (value: INTEGER_64; key: JSON_STRING)
-- Assuming there is no item of key `key',
-- insert `value' with `key'.

View File

@@ -1,30 +1,26 @@
note
description: "[
A JSON_STRING represent a string in JSON.
A string is a collection of zero or more Unicodes characters, wrapped in double
quotes, using blackslash espaces.
]"
author: "Javier Velilla"
date: "2008/08/24"
revision: "Revision 0.1"
license: "MIT (see http://www.opensource.org/licenses/mit-license.php)"
class
JSON_STRING
inherit
JSON_VALUE
redefine
is_equal
end
create
make_json,
make_json_from_string_32,
make_with_escaped_json
make_json, make_json_from_string_32, make_with_escaped_json
convert
make_json ({READABLE_STRING_8, STRING_8, IMMUTABLE_STRING_8}),
@@ -105,7 +101,11 @@ feature -- Conversion
do
s := item
n := s.count
from i := 1 until i > n loop
from
i := 1
until
i > n
loop
c := s [i]
if c = '\' then
if i < n then
@@ -163,7 +163,11 @@ feature -- Conversion
do
s := item
n := s.count
from i := 1 until i > n loop
from
i := 1
until
i > n
loop
ch := s.item (i)
if ch = '\' then
if i < n then
@@ -207,37 +211,27 @@ feature -- Conversion
c := ch.natural_32_code
if c <= 0x7F then
-- 0xxxxxxx
check ch = c.to_character_32 end
check
ch = c.to_character_32
end
a_output.append_character (ch)
elseif c <= 0xDF then
-- 110xxxxx 10xxxxxx
i := i + 1
if i <= n then
a_output.append_code (
((c & 0x1F) |<< 6) |
(s.code (i) & 0x3F)
)
a_output.append_code (((c & 0x1F) |<< 6) | (s.code (i) & 0x3F))
end
elseif c <= 0xEF then
-- 1110xxxx 10xxxxxx 10xxxxxx
i := i + 2
if i <= n then
a_output.append_code (
((c & 0xF) |<< 12) |
((s.code (i - 1) & 0x3F) |<< 6) |
(s.code (i) & 0x3F)
)
a_output.append_code (((c & 0xF) |<< 12) | ((s.code (i - 1) & 0x3F) |<< 6) | (s.code (i) & 0x3F))
end
elseif c <= 0xF7 then
-- 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
i := i + 3
if i <= n then
a_output.append_code (
((c & 0x7) |<< 18) |
((s.code (i - 2) & 0x3F) |<< 12) |
((s.code (i - 1) & 0x3F) |<< 6) |
(s.code (i) & 0x3F)
)
a_output.append_code (((c & 0x7) |<< 18) | ((s.code (i - 2) & 0x3F) |<< 12) | ((s.code (i - 1) & 0x3F) |<< 6) | (s.code (i) & 0x3F))
end
end
i := i + 1
@@ -317,13 +311,11 @@ feature {NONE} -- Implementation
char: CHARACTER
do
nb := s.count
if nb >= 2 and then s.item (2) = 'x' then
i := 3
else
i := 1
end
from
until
i > nb
@@ -349,16 +341,27 @@ feature {NONE} -- Implementation
do
n := s.count
create Result.make (n + n // 10)
from i := 1 until i > n loop
from
i := 1
until
i > n
loop
c := s.item (i)
inspect c
when '%"' then Result.append_string ("\%"")
when '\' then Result.append_string ("\\")
when '%B' then Result.append_string ("\b")
when '%F' then Result.append_string ("\f")
when '%N' then Result.append_string ("\n")
when '%R' then Result.append_string ("\r")
when '%T' then Result.append_string ("\t")
when '%"' then
Result.append_string ("\%"")
when '\' then
Result.append_string ("\\")
when '%B' then
Result.append_string ("\b")
when '%F' then
Result.append_string ("\f")
when '%N' then
Result.append_string ("\n")
when '%R' then
Result.append_string ("\r")
when '%T' then
Result.append_string ("\t")
else
Result.extend (c)
end
@@ -378,18 +381,29 @@ feature {NONE} -- Implementation
do
n := s.count
create Result.make (n + n // 10)
from i := 1 until i > n loop
from
i := 1
until
i > n
loop
uc := s.item (i)
if uc.is_character_8 then
c := uc.to_character_8
inspect c
when '%"' then Result.append_string ("\%"")
when '\' then Result.append_string ("\\")
when '%B' then Result.append_string ("\b")
when '%F' then Result.append_string ("\f")
when '%N' then Result.append_string ("\n")
when '%R' then Result.append_string ("\r")
when '%T' then Result.append_string ("\t")
when '%"' then
Result.append_string ("\%"")
when '\' then
Result.append_string ("\\")
when '%B' then
Result.append_string ("\b")
when '%F' then
Result.append_string ("\f")
when '%N' then
Result.append_string ("\n")
when '%R' then
Result.append_string ("\r")
when '%T' then
Result.append_string ("\t")
else
Result.extend (c)
end
@@ -405,14 +419,15 @@ feature {NONE} -- Implementation
j := j + 1
end
h := h.substring (j, h.count)
from
until
h.count >= 4
loop
h.prepend_integer (0)
end
check h.count = 4 end
check
h.count = 4
end
Result.append (h)
end
i := i + 1

View File

@@ -14,11 +14,11 @@ note
revision: "Revision 0.1"
license: "MIT (see http://www.opensource.org/licenses/mit-license.php)"
deferred class
JSON_VALUE
inherit
HASHABLE
DEBUG_OUTPUT

View File

@@ -1,5 +1,4 @@
note
description: "Parse serialized JSON data"
author: "jvelilla"
date: "2008/08/24"
@@ -9,7 +8,9 @@ class
JSON_PARSER
inherit
JSON_READER
JSON_TOKENS
create
@@ -139,7 +140,11 @@ feature -- Commands
else
-- a complex object {"key" : "value"}
previous
from has_more := True until not has_more loop
from
has_more := True
until
not has_more
loop
next
skip_white_spaces
l_json_string := parse_string
@@ -153,7 +158,6 @@ feature -- Commands
report_error ("%N Input string is a not well formed JSON, expected: : found: " + actual.out)
has_more := False
end
l_value := parse
if is_parsed and then (l_value /= Void and l_json_string /= Void) then
Result.put (l_value, l_json_string)
@@ -286,7 +290,6 @@ feature -- Commands
do
create sb.make_empty
sb.append_character (actual)
from
flag := True
until
@@ -294,16 +297,13 @@ feature -- Commands
loop
next
c := actual
if not has_next or is_close_token (c)
or c = ',' or c = '%N' or c = '%R'
then
if not has_next or is_close_token (c) or c = ',' or c = '%N' or c = '%R' then
flag := False
previous
else
sb.append_character (c)
end
end
if is_valid_number (sb) then
if sb.is_integer then
create Result.make_integer (sb.to_integer)
@@ -393,19 +393,30 @@ feature {NONE} -- Implementation
--| "-?"
c := a_number [i]
if c = '-' then
s.extend (c); i := i + 1; c := a_number[i]
s.extend (c);
i := i + 1;
c := a_number [i]
end
--| "0|[1-9]\d*
if c.is_digit then
if c = '0' then
--| "0"
s.extend (c); i := i + 1; c := a_number[i]
s.extend (c);
i := i + 1;
c := a_number [i]
else
--| "[1-9]"
s.extend (c); i := i + 1; c := a_number[i]
s.extend (c);
i := i + 1;
c := a_number [i]
--| "\d*"
from until i > n or not c.is_digit loop
s.extend (c); i := i + 1; c := a_number[i]
from
until
i > n or not c.is_digit
loop
s.extend (c);
i := i + 1;
c := a_number [i]
end
end
end
@@ -414,10 +425,17 @@ feature {NONE} -- Implementation
--| "(\.\d+)?"
if c = '.' then
--| "\.\d+" = "\.\d\d*"
s.extend (c); i := i + 1; c := a_number[i]
s.extend (c);
i := i + 1;
c := a_number [i]
if c.is_digit then
from until i > n or not c.is_digit loop
s.extend (c); i := i + 1; c := a_number[i]
from
until
i > n or not c.is_digit
loop
s.extend (c);
i := i + 1;
c := a_number [i]
end
else
Result := False --| expecting digit
@@ -427,13 +445,22 @@ feature {NONE} -- Implementation
if Result then --| "(?:[eE][+-]?\d+)?\b"
if c = 'e' or c = 'E' then
--| "[eE][+-]?\d+"
s.extend (c); i := i + 1; c := a_number[i]
s.extend (c);
i := i + 1;
c := a_number [i]
if c = '+' or c = '-' then
s.extend (c); i := i + 1; c := a_number[i]
s.extend (c);
i := i + 1;
c := a_number [i]
end
if c.is_digit then
from until i > n or not c.is_digit loop
s.extend (c); i := i + 1; c := a_number[i]
from
until
i > n or not c.is_digit
loop
s.extend (c);
i := i + 1;
c := a_number [i]
end
else
Result := False --| expecting digit
@@ -441,8 +468,13 @@ feature {NONE} -- Implementation
end
end
if Result then --| "\b"
from until i > n or not c.is_space loop
s.extend (c); i := i + 1; c := a_number[i]
from
until
i > n or not c.is_space
loop
s.extend (c);
i := i + 1;
c := a_number [i]
end
Result := i > n and then s.same_string (a_number)
end
@@ -454,11 +486,7 @@ feature {NONE} -- Implementation
local
i: INTEGER
do
if
a_unicode.count = 6 and then
a_unicode[1] = '\' and then
a_unicode[2] = 'u'
then
if a_unicode.count = 6 and then a_unicode [1] = '\' and then a_unicode [2] = 'u' then
from
Result := True
i := 3
@@ -509,5 +537,4 @@ feature {NONE} -- Constants
null_id: STRING = "null"
end

View File

@@ -10,13 +10,19 @@ class
feature -- Access
j_OBJECT_OPEN: CHARACTER = '{'
j_ARRAY_OPEN: CHARACTER = '['
j_OBJECT_CLOSE: CHARACTER = '}'
j_ARRAY_CLOSE: CHARACTER = ']'
j_STRING: CHARACTER = '"'
j_PLUS: CHARACTER = '+'
j_MINUS: CHARACTER = '-'
j_DOT: CHARACTER = '.'
feature -- Status report
@@ -28,7 +34,6 @@ feature -- Status report
when j_OBJECT_OPEN, j_ARRAY_OPEN, j_STRING, j_PLUS, j_MINUS, j_DOT then
Result := True
else
end
end
@@ -39,7 +44,6 @@ feature -- Status report
when j_OBJECT_CLOSE, j_ARRAY_CLOSE, j_STRING then
Result := True
else
end
end
@@ -58,7 +62,6 @@ feature -- Status report
when '%F', '%H', '%N', '%R', '%T', '%B', '/', '"' then
Result := True
else
end
end
@@ -70,7 +73,6 @@ feature -- Status report
when 'b', 'f', 'n', 'r', 't' then
Result := True
else
end
end

View File

@@ -11,7 +11,8 @@ note
revision: "$Revision: 89185 $"
file: "$HeadURL: $"
class SHARED_EJSON
class
SHARED_EJSON
feature
@@ -24,13 +25,10 @@ feature
jhtc: JSON_HASH_TABLE_CONVERTER
once
create Result
create jalc.make
Result.add_converter (jalc)
create jllc.make
Result.add_converter (jllc)
create jhtc.make
Result.add_converter (jhtc)
end

View File

@@ -7,6 +7,7 @@ class
APPLICATION
inherit
ARGUMENTS
create

View File

@@ -1,4 +1,3 @@
class
AUTHOR

View File

@@ -1,4 +1,3 @@
class
BOOK
@@ -9,7 +8,7 @@ feature {NONE} -- Initialization
make (a_title: STRING_32; a_author: AUTHOR; a_isbn: STRING_32)
-- Create a book with `a_title' as `title',
-- `a_author' as `author', and `a_isbn' as `isbn',
-- `a_author' as `author', and `a_isbn' as `isbn'.
do
set_title (a_title)
set_author (a_author)

View File

@@ -7,7 +7,7 @@ create
feature {NONE} -- Initialization
make (a_name: STRING_32)
-- Create a collection of book with `a_name' as `name'
-- Create a book collection with `a_name' as `name'.
do
set_name (a_name)
create book_index.make (10)
@@ -24,7 +24,9 @@ feature -- Access
-- collection of book.
do
create {LINKED_LIST [BOOK]} Result.make
across book_index as it loop
across
book_index as it
loop
Result.append (it.item)
end
end
@@ -65,7 +67,9 @@ feature -- Change
add_books (book_list: like books)
-- Append collection with `book_list'.
do
across book_list as it loop
across
book_list as it
loop
add_book (it.item)
end
end

View File

@@ -8,6 +8,7 @@ class
JSON_AUTHOR_CONVERTER
inherit
JSON_CONVERTER
create

View File

@@ -8,6 +8,7 @@ class
JSON_BOOK_COLLECTION_CONVERTER
inherit
JSON_CONVERTER
create
@@ -39,7 +40,6 @@ feature -- Conversion
then
create Result.make (l_name)
create l_books.make
across
l_json_array as it
until
@@ -52,7 +52,6 @@ feature -- Conversion
-- Failed
end
end
if Result /= Void then
Result.add_books (l_books)
end

View File

@@ -8,6 +8,7 @@ class
JSON_BOOK_CONVERTER
inherit
JSON_CONVERTER
create

View File

@@ -1,4 +1,3 @@
note
description: "Linked list and hash table converters test."
date: "$Date$"
@@ -8,6 +7,7 @@ class
TEST_DS
inherit
SHARED_EJSON
undefine
default_create
@@ -27,7 +27,6 @@ feature -- Test
create l.make
l.force ("foo")
l.force ("bar")
if attached json.value (l) as l_value then
s := l_value.representation
assert ("JSON array converted to LINKED_LIST", attached {LINKED_LIST [detachable ANY]} json.object (l_value, "LINKED_LIST"))
@@ -47,18 +46,15 @@ feature -- Test
create t.make (2)
t.put ("foo", "1")
t.put ("bar", "2")
if attached json.value (t) as l_value then
s := l_value.representation
if attached {HASH_TABLE [ANY, HASHABLE]} json.object (l_value, "HASH_TABLE") as t2 then
create l_ucs_key.make_from_string ("1")
if attached {STRING_32} t2 [l_ucs_key] as l_ucs_value then
assert ("ucs_value.string.is_equal (%"foo%")", l_ucs_value.string.is_equal ("foo"))
else
assert ("ucs_value /= Void", False)
end
create l_ucs_key.make_from_string ("2")
if attached {STRING_32} t2 [l_ucs_key] as l_ucs_value then
assert ("ucs_value.string.is_equal (%"bar%")", l_ucs_value.string.is_equal ("bar"))

View File

@@ -1,7 +1,8 @@
class
class
TEST_JSON_CORE
inherit
SHARED_EJSON
undefine
default_create
@@ -487,7 +488,6 @@ feature -- Test
-- Eiffel value -> JSON value -> JSON representation
create jn
jrep := "null"
assert ("jn.representation.is_equal (%"%"null%"%")", jn.representation.is_equal (jrep))
-- Eiffel value -> JSON value -> JSON representation with factory
if attached {JSON_NULL} json.value (Void) as l_json_null then
@@ -515,7 +515,6 @@ feature -- Test
c := 'a'
-- Eiffel value -> JSON value -> JSON representation
create js.make_json (c.out)
assert ("js.representation.is_equal (%"%"a%"%")", js.representation.is_equal ("%"a%""))
-- Eiffel value -> JSON value -> JSON representation with factory
if attached {JSON_STRING} json.value (c) as l_json_str then
@@ -612,7 +611,6 @@ feature -- Test
jrep := "%"foo\\bar%""
create s.make_from_string ("foo\bar")
create js.make_json (s)
assert ("js.representation.same_string (%"%"foo\\bar%"%")", js.representation.same_string (jrep))
-- Eiffel value -> JSON value -> JSON representation with factory
@@ -631,8 +629,6 @@ feature -- Test
else
assert ("parser.parse /= Void", False)
end
jrep := "%"foo\\bar%""
create parser.make_parser (jrep)
if attached {JSON_STRING} parser.parse as jstring then
@@ -640,14 +636,12 @@ feature -- Test
else
assert ("parser.parse /= Void", False)
end
create js.make_json_from_string_32 ({STRING_32}"%/20320/%/22909/")
create js.make_json_from_string_32 ({STRING_32} "你好")
assert ("escaping unicode string32 %"%%/20320/%%/22909/%" %"\u4F60\u597D%"", js.item.same_string ("\u4F60\u597D"))
jrep := "%"\u4F60\u597D%"" --| Ni hao
create parser.make_parser (jrep)
if attached {JSON_STRING} parser.parse as jstring then
assert ("same unicode string32 %"%%/20320/%%/22909/%"", jstring.unescaped_string_32.same_string ({STRING_32}"%/20320/%/22909/"))
assert ("same unicode string32 %"%%/20320/%%/22909/%"", jstring.unescaped_string_32.same_string ({STRING_32} "你好"))
else
assert ("parser.parse /= Void", False)
end

View File

@@ -1,4 +1,3 @@
note
description: "Parsing and converter of book collection test."
date: "$Date$"
@@ -8,6 +7,7 @@ class
TEST_JSON_CUSTOM_CLASSES
inherit
SHARED_EJSON
undefine
default_create
@@ -34,7 +34,6 @@ feature -- Test
json.add_converter (jac)
jrep := "{%"name%":%"Test collection%",%"books%":[{%"title%":%"eJSON: The Definitive Guide%",%"isbn%":%"123123-413243%",%"author%":{%"name%":%"Foo Bar%"}}]}"
create parser.make_parser (jrep)
if attached {JSON_OBJECT} parser.parse as l_json_object then
if attached {BOOK_COLLECTION} json.object (l_json_object, "BOOK_COLLECTION") as l_collection then
if attached {JSON_OBJECT} json.value (l_collection) as l_json_object_2 then

View File

@@ -11,6 +11,7 @@ class
TEST_JSON_SUITE
inherit
EQA_TEST_SET
redefine
on_prepare
@@ -69,14 +70,10 @@ feature -- Tests Pass
s: READABLE_STRING_32
do
s := {STRING_32} "{ %"nihaoma%": %"你好吗\t?%" }"
parse_json := new_json_parser (utf.string_32_to_utf_8_string_8 (s))
json_value := parse_json.parse_json
assert ("utf8.pass1.json", parse_json.is_parsed = True)
if
attached {JSON_OBJECT} json_value as jo and then
attached {JSON_STRING} jo.item ("nihaoma") as js
then
if attached {JSON_OBJECT} json_value as jo and then attached {JSON_STRING} jo.item ("nihaoma") as js then
assert ("utf8.nihaoma", js.unescaped_string_32.same_string ({STRING_32} "你好吗%T?"))
else
assert ("utf8.nihaoma", False)
@@ -84,6 +81,7 @@ feature -- Tests Pass
end
feature -- Tests Failures
test_json_fail1
--
local
@@ -144,7 +142,6 @@ feature -- Tests Failures
end
end
test_json_fail6
--
local
@@ -181,7 +178,6 @@ feature -- Tests Failures
end
end
test_json_fail9
--
local
@@ -194,7 +190,6 @@ feature -- Tests Failures
end
end
test_json_fail10
--
local
@@ -339,7 +334,6 @@ feature -- Tests Failures
end
end
test_json_fail22
--
local
@@ -388,7 +382,6 @@ feature -- Tests Failures
end
end
test_json_fail26
--
local
@@ -401,7 +394,6 @@ feature -- Tests Failures
end
end
test_json_fail27
--
local
@@ -414,7 +406,6 @@ feature -- Tests Failures
end
end
test_json_fail28
--
local
@@ -427,7 +418,6 @@ feature -- Tests Failures
end
end
test_json_fail29
--
local
@@ -440,7 +430,6 @@ feature -- Tests Failures
end
end
test_json_fail30
--
local
@@ -504,7 +493,6 @@ feature -- JSON_FROM_FILE
do
test_dir := (create {EXECUTION_ENVIRONMENT}).current_working_directory
test_dir.append_character ((create {OPERATING_ENVIRONMENT}).directory_separator)
l_path := test_dir + fn
create f.make_with_name (l_path)
if f.exists then
@@ -536,9 +524,7 @@ feature -- JSON_FROM_FILE
create Result.make_parser (a_string)
end
invariant
file_reader /= Void
end