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

@@ -1,12 +1,13 @@
note
description : "test_suite application root class"
date : "$Date$"
revision : "$Revision$"
description: "test_suite application root class"
date: "$Date$"
revision: "$Revision$"
class
APPLICATION
inherit
ARGUMENTS
create
@@ -17,7 +18,7 @@ feature {NONE} -- Initialization
make
-- Run application.
do
--| Add your code here
--| Add your code here
print ("Hello Eiffel World!%N")
end

View File

@@ -1,33 +1,32 @@
class
AUTHOR
create
make
make
feature {NONE} -- Initialization
make (a_name: STRING_32)
make (a_name: STRING_32)
-- Create an author with `a_name' as `name'.
do
set_name (a_name)
ensure
do
set_name (a_name)
ensure
name_set: name = a_name
end
end
feature -- Access
name: STRING_32
-- Author name
name: STRING_32
-- Author name
feature -- Change
set_name (a_name: STRING_32)
set_name (a_name: STRING_32)
-- Set `name' with `a_name'.
do
name := a_name
ensure
do
name := a_name
ensure
name_set: name = a_name
end
end
end -- class AUTHOR

View File

@@ -1,60 +1,59 @@
class
BOOK
create
make
make
feature {NONE} -- Initialization
make (a_title: STRING_32; a_author: AUTHOR; a_isbn: STRING_32)
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',
do
set_title (a_title)
set_author (a_author)
set_isbn (a_isbn)
ensure
-- `a_author' as `author', and `a_isbn' as `isbn'.
do
set_title (a_title)
set_author (a_author)
set_isbn (a_isbn)
ensure
title_set: title = a_title
author_set: author = a_author
isbn_set: isbn = a_isbn
end
end
feature -- Access
title: STRING_32
title: STRING_32
-- Main title.
isbn: STRING_32
isbn: STRING_32
-- ISBN.
author: AUTHOR
author: AUTHOR
-- Author.
feature -- Change
set_title (a_title: STRING_32)
set_title (a_title: STRING_32)
-- Set `title' with `a_title'.
do
title := a_title
ensure
do
title := a_title
ensure
title_set: title = a_title
end
end
set_author (a_author: AUTHOR)
set_author (a_author: AUTHOR)
-- Set `author' with `a_author'.
do
author := a_author
ensure
do
author := a_author
ensure
author_set: author = a_author
end
end
set_isbn (a_isbn: STRING_32)
set_isbn (a_isbn: STRING_32)
-- Set `isbn' with `a_isbn'.
do
isbn := a_isbn
ensure
do
isbn := a_isbn
ensure
isbn_set: isbn = a_isbn
end
end
end -- class BOOK

View File

@@ -2,77 +2,81 @@ class
BOOK_COLLECTION
create
make
make
feature {NONE} -- Initialization
make (a_name: STRING_32)
-- Create a collection of book with `a_name' as `name'
do
set_name (a_name)
create book_index.make (10)
ensure
make (a_name: STRING_32)
-- Create a book collection with `a_name' as `name'.
do
set_name (a_name)
create book_index.make (10)
ensure
name_set: name = a_name
end
end
feature -- Access
name: STRING_32
name: STRING_32
-- Name.
books: LIST [BOOK]
books: LIST [BOOK]
-- collection of book.
do
create {LINKED_LIST [BOOK]} Result.make
across book_index as it loop
do
create {LINKED_LIST [BOOK]} Result.make
across
book_index as it
loop
Result.append (it.item)
end
end
end
end
books_by_author (a_author: STRING_32): LIST [BOOK]
books_by_author (a_author: STRING_32): LIST [BOOK]
-- Books wrote by `a_author' in this collection.
do
if attached book_index [a_author] as l_result then
Result := l_result
else
create {LINKED_LIST [BOOK]} Result.make
end
end
do
if attached book_index [a_author] as l_result then
Result := l_result
else
create {LINKED_LIST [BOOK]} Result.make
end
end
feature -- Change
set_name (a_name: STRING_32)
set_name (a_name: STRING_32)
-- Set `name' with `a_name'.
do
name := a_name
ensure
do
name := a_name
ensure
name_set: name = a_name
end
end
add_book (a_book: BOOK)
add_book (a_book: BOOK)
-- Extend collection with `a_book'.
local
l: detachable LIST [BOOK]
do
l := book_index.at (a_book.author.name )
if l = Void then
create {LINKED_LIST [BOOK]} l.make
book_index.put (l, a_book.author.name)
end
l.force (a_book)
end
local
l: detachable LIST [BOOK]
do
l := book_index.at (a_book.author.name)
if l = Void then
create {LINKED_LIST [BOOK]} l.make
book_index.put (l, a_book.author.name)
end
l.force (a_book)
end
add_books (book_list: like books)
add_books (book_list: like books)
-- Append collection with `book_list'.
do
across book_list as it loop
do
across
book_list as it
loop
add_book (it.item)
end
end
end
end
feature {NONE} -- Implementation
book_index: HASH_TABLE [LIST [BOOK], STRING_32]
book_index: HASH_TABLE [LIST [BOOK], STRING_32]
-- Association of author name and its books.
end -- class BOOK_COLLECTION

View File

@@ -1,53 +1,54 @@
note
description: "A JSON converter for AUTHOR"
author: "Paul Cohen"
date: "$Date$"
revision: "$Revision$"
description: "A JSON converter for AUTHOR"
author: "Paul Cohen"
date: "$Date$"
revision: "$Revision$"
class
JSON_AUTHOR_CONVERTER
inherit
JSON_CONVERTER
JSON_CONVERTER
create
make
make
feature {NONE} -- Initialization
make
local
ucs: STRING_32
do
create ucs.make_from_string ("")
create object.make (ucs)
end
make
local
ucs: STRING_32
do
create ucs.make_from_string ("")
create object.make (ucs)
end
feature -- Access
object: AUTHOR
object: AUTHOR
feature -- Conversion
from_json (j: like to_json): detachable like object
do
if attached {STRING_32} json.object (j.item (name_key), Void) as l_name then
from_json (j: like to_json): detachable like object
do
if attached {STRING_32} json.object (j.item (name_key), Void) as l_name then
create Result.make (l_name)
end
end
end
end
to_json (o: like object): JSON_OBJECT
do
create Result.make
Result.put (json.value (o.name), name_key)
end
to_json (o: like object): JSON_OBJECT
do
create Result.make
Result.put (json.value (o.name), name_key)
end
feature {NONE} -- Implementation
name_key: JSON_STRING
name_key: JSON_STRING
-- Author's name label.
once
create Result.make_json ("name")
end
once
create Result.make_json ("name")
end
end -- class JSON_AUTHOR_CONVERTER

View File

@@ -1,45 +1,45 @@
note
description: "A JSON converter for BOOK_COLLECTION"
author: "Paul Cohen"
date: "$Date$"
revision: "$Revision$"
description: "A JSON converter for BOOK_COLLECTION"
author: "Paul Cohen"
date: "$Date$"
revision: "$Revision$"
class
JSON_BOOK_COLLECTION_CONVERTER
inherit
JSON_CONVERTER
JSON_CONVERTER
create
make
make
feature {NONE} -- Initialization
make
local
ucs: STRING_32
do
create ucs.make_from_string ("")
create object.make (ucs)
end
make
local
ucs: STRING_32
do
create ucs.make_from_string ("")
create object.make (ucs)
end
feature -- Access
object: BOOK_COLLECTION
object: BOOK_COLLECTION
feature -- Conversion
from_json (j: like to_json): detachable like object
local
l_books: LINKED_LIST [BOOK]
do
if
from_json (j: like to_json): detachable like object
local
l_books: LINKED_LIST [BOOK]
do
if
attached {STRING_32} json.object (j.item (name_key), Void) as l_name and
attached {JSON_ARRAY} j.item (books_key) as l_json_array
then
then
create Result.make (l_name)
create l_books.make
across
l_json_array as it
until
@@ -52,32 +52,31 @@ feature -- Conversion
-- Failed
end
end
if Result /= Void then
Result.add_books (l_books)
end
end
end
end
end
to_json (o: like object): JSON_OBJECT
do
create Result.make
Result.put (json.value (o.name), name_key)
Result.put (json.value (o.books), books_key)
end
to_json (o: like object): JSON_OBJECT
do
create Result.make
Result.put (json.value (o.name), name_key)
Result.put (json.value (o.books), books_key)
end
feature {NONE} -- Implementation
feature {NONE} -- Implementation
name_key: JSON_STRING
name_key: JSON_STRING
-- Collection's name label.
once
create Result.make_json ("name")
end
once
create Result.make_json ("name")
end
books_key: JSON_STRING
books_key: JSON_STRING
-- Book list label.
once
create Result.make_json ("books")
end
once
create Result.make_json ("books")
end
end -- class JSON_BOOK_COLLECTION_CONVERTER

View File

@@ -1,73 +1,74 @@
note
description: "A JSON converter for BOOK"
author: "Paul Cohen"
date: "$Date$"
revision: "$Revision$"
description: "A JSON converter for BOOK"
author: "Paul Cohen"
date: "$Date$"
revision: "$Revision$"
class
JSON_BOOK_CONVERTER
inherit
JSON_CONVERTER
JSON_CONVERTER
create
make
make
feature {NONE} -- Initialization
make
local
ucs: STRING_32
a: AUTHOR
do
create ucs.make_from_string ("")
create a.make (ucs)
create object.make (ucs, a, ucs)
end
make
local
ucs: STRING_32
a: AUTHOR
do
create ucs.make_from_string ("")
create a.make (ucs)
create object.make (ucs, a, ucs)
end
feature -- Access
object: BOOK
object: BOOK
feature -- Conversion
from_json (j: like to_json): detachable like object
do
if
from_json (j: like to_json): detachable like object
do
if
attached {STRING_32} json.object (j.item (title_key), Void) as l_title and
attached {STRING_32} json.object (j.item (isbn_key), Void) as l_isbn and
attached {AUTHOR} json.object (j.item (author_key), "AUTHOR") as l_author
then
then
create Result.make (l_title, l_author, l_isbn)
end
end
end
end
to_json (o: like object): JSON_OBJECT
do
create Result.make
Result.put (json.value (o.title), title_key)
Result.put (json.value (o.isbn), isbn_key)
Result.put (json.value (o.author), author_key)
end
to_json (o: like object): JSON_OBJECT
do
create Result.make
Result.put (json.value (o.title), title_key)
Result.put (json.value (o.isbn), isbn_key)
Result.put (json.value (o.author), author_key)
end
feature {NONE} -- Implementation
title_key: JSON_STRING
title_key: JSON_STRING
-- Book's title label.
once
create Result.make_json ("title")
end
once
create Result.make_json ("title")
end
isbn_key: JSON_STRING
isbn_key: JSON_STRING
-- Book ISBN label.
once
create Result.make_json ("isbn")
end
once
create Result.make_json ("isbn")
end
author_key: JSON_STRING
author_key: JSON_STRING
-- Author label.
once
create Result.make_json ("author")
end
once
create Result.make_json ("author")
end
end -- class JSON_BOOK_CONVERTER

View File

@@ -1,14 +1,14 @@
note
description: "Linked list and hash table converters test."
date: "$Date$"
revision: "$Revision$"
description: "Linked list and hash table converters test."
date: "$Date$"
revision: "$Revision$"
class
TEST_DS
inherit
SHARED_EJSON
SHARED_EJSON
undefine
default_create
end
@@ -17,60 +17,56 @@ inherit
feature -- Test
test_linked_list_converter
test_linked_list_converter
-- Convert a linked list to a json value and
-- convert this one to a linked list.
local
l: LINKED_LIST [STRING]
s: STRING
do
create l.make
l.force ("foo")
l.force ("bar")
local
l: LINKED_LIST [STRING]
s: STRING
do
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"))
else
assert ("LINKED_LIST converted to a JSON value", False)
end
end
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"))
else
assert ("LINKED_LIST converted to a JSON value", False)
end
end
test_hash_table_converter
test_hash_table_converter
-- Convert a hash table to a json value and
-- convert this one to a hash table.
local
t: HASH_TABLE [STRING, STRING]
s: STRING
l_ucs_key: detachable STRING_32
do
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"))
else
assert ("ucs_value /= Void", False)
end
else
assert ("JSON object converted to HASH_TABLE", False);
end
else
assert ("HASH_TABLE converted to a JSON value", False)
end
end
local
t: HASH_TABLE [STRING, STRING]
s: STRING
l_ucs_key: detachable STRING_32
do
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"))
else
assert ("ucs_value /= Void", False)
end
else
assert ("JSON object converted to HASH_TABLE", False);
end
else
assert ("HASH_TABLE converted to a JSON value", False)
end
end
end -- class TEST_DS

File diff suppressed because it is too large Load Diff

View File

@@ -1,14 +1,14 @@
note
description: "Parsing and converter of book collection test."
date: "$Date$"
revision: "$Revision$"
description: "Parsing and converter of book collection test."
date: "$Date$"
revision: "$Revision$"
class
TEST_JSON_CUSTOM_CLASSES
inherit
SHARED_EJSON
SHARED_EJSON
undefine
default_create
end
@@ -17,25 +17,24 @@ inherit
feature -- Test
test_custom_classes
test_custom_classes
-- Parse JSON representation to JSON_OBJECT and test book collection converter.
local
jbc: JSON_BOOK_CONVERTER
jbcc: JSON_BOOK_COLLECTION_CONVERTER
jac: JSON_AUTHOR_CONVERTER
parser: JSON_PARSER
jrep: STRING
do
create jbc.make
json.add_converter (jbc)
create jbcc.make
json.add_converter (jbcc)
create jac.make
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
local
jbc: JSON_BOOK_CONVERTER
jbcc: JSON_BOOK_COLLECTION_CONVERTER
jac: JSON_AUTHOR_CONVERTER
parser: JSON_PARSER
jrep: STRING
do
create jbc.make
json.add_converter (jbc)
create jbcc.make
json.add_converter (jbcc)
create jac.make
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
assert ("JSON representation is correct", l_json_object_2.representation.same_string (jrep))
@@ -47,7 +46,7 @@ feature -- Test
end
else
assert ("JSON object representation to JSON_OBJECT", False)
end
end
end
end
end -- class TEST_JSON_CUSTOM_CLASS

View File

@@ -11,6 +11,7 @@ class
TEST_JSON_SUITE
inherit
EQA_TEST_SET
redefine
on_prepare
@@ -27,38 +28,38 @@ feature {NONE} -- Events
feature -- Tests Pass
test_json_pass1
--
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("pass1.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("pass1.json",parse_json.is_parsed = True)
assert ("pass1.json", parse_json.is_parsed = True)
end
end
test_json_pass2
--
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("pass2.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("pass2.json",parse_json.is_parsed = True)
assert ("pass2.json", parse_json.is_parsed = True)
end
end
test_json_pass3
--
test_json_pass3
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("pass3.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("pass3.json",parse_json.is_parsed = True)
assert ("pass3.json", parse_json.is_parsed = True)
end
end
@@ -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,408 +81,400 @@ feature -- Tests Pass
end
feature -- Tests Failures
test_json_fail1
--
test_json_fail1
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail1.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail1.json",parse_json.is_parsed = False)
assert ("fail1.json", parse_json.is_parsed = False)
end
end
test_json_fail2
--
test_json_fail2
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail2.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail2.json",parse_json.is_parsed = False)
assert ("fail2.json", parse_json.is_parsed = False)
end
end
test_json_fail3
--
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail3.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail3.json",parse_json.is_parsed = False)
assert ("fail3.json", parse_json.is_parsed = False)
end
end
test_json_fail4
--
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail4.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail4.json",parse_json.is_parsed = False)
assert ("fail4.json", parse_json.is_parsed = False)
end
end
test_json_fail5
--
test_json_fail5
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail5.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail5.json",parse_json.is_parsed = False)
assert ("fail5.json", parse_json.is_parsed = False)
end
end
test_json_fail6
--
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail6.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail6.json",parse_json.is_parsed = False )
assert ("fail6.json", parse_json.is_parsed = False)
end
end
test_json_fail7
--
test_json_fail7
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail7.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail7.json",parse_json.is_parsed = False)
assert ("fail7.json", parse_json.is_parsed = False)
end
end
test_json_fail8
--
test_json_fail8
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail8.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail8.json",parse_json.is_parsed = False )
assert ("fail8.json", parse_json.is_parsed = False)
end
end
test_json_fail9
--
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail9.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail9.json",parse_json.is_parsed = False)
assert ("fail9.json", parse_json.is_parsed = False)
end
end
test_json_fail10
--
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail10.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail10.json",parse_json.is_parsed = False)
assert ("fail10.json", parse_json.is_parsed = False)
end
end
test_json_fail11
--
test_json_fail11
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail11.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail11.json",parse_json.is_parsed = False)
assert ("fail11.json", parse_json.is_parsed = False)
end
end
test_json_fail12
--
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail12.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail12.json",parse_json.is_parsed = False)
assert ("fail12.json", parse_json.is_parsed = False)
end
end
test_json_fail13
--
test_json_fail13
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail13.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail13.json",parse_json.is_parsed = False)
assert ("fail13.json", parse_json.is_parsed = False)
end
end
test_json_fail14
--
test_json_fail14
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail14.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail14.json",parse_json.is_parsed = False)
assert ("fail14.json", parse_json.is_parsed = False)
end
end
test_json_fail15
--
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail15.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail15.json",parse_json.is_parsed = False)
assert ("fail15.json", parse_json.is_parsed = False)
end
end
test_json_fail16
--
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail16.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail16.json",parse_json.is_parsed = False)
assert ("fail16.json", parse_json.is_parsed = False)
end
end
test_json_fail17
--
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail17.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail17.json",parse_json.is_parsed = False)
assert ("fail17.json", parse_json.is_parsed = False)
end
end
test_json_fail18
--
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail18.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail18.json",parse_json.is_parsed = True)
assert ("fail18.json", parse_json.is_parsed = True)
end
end
test_json_fail19
--
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail19.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail19.json",parse_json.is_parsed = False)
assert ("fail19.json", parse_json.is_parsed = False)
end
end
test_json_fail20
--
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail20.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail20.json",parse_json.is_parsed = False)
assert ("fail20.json", parse_json.is_parsed = False)
end
end
test_json_fail21
--
test_json_fail21
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail21.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail21.json",parse_json.is_parsed = False)
assert ("fail21.json", parse_json.is_parsed = False)
end
end
test_json_fail22
--
test_json_fail22
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail22.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail22.json",parse_json.is_parsed = False)
assert ("fail22.json", parse_json.is_parsed = False)
end
end
test_json_fail23
--
test_json_fail23
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail23.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail23.json",parse_json.is_parsed = False)
assert ("fail23.json", parse_json.is_parsed = False)
end
end
test_json_fail24
--
test_json_fail24
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail24.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail24.json",parse_json.is_parsed = False)
assert ("fail24.json", parse_json.is_parsed = False)
end
end
test_json_fail25
--
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail25.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail25.json",parse_json.is_parsed = False)
assert ("fail25.json", parse_json.is_parsed = False)
end
end
test_json_fail26
--
test_json_fail26
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail26.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail26.json",parse_json.is_parsed = False)
assert ("fail26.json", parse_json.is_parsed = False)
end
end
test_json_fail27
--
test_json_fail27
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail27.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail27.json",parse_json.is_parsed = False)
assert ("fail27.json", parse_json.is_parsed = False)
end
end
test_json_fail28
--
test_json_fail28
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail28.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail28.json",parse_json.is_parsed = False)
assert ("fail28.json", parse_json.is_parsed = False)
end
end
test_json_fail29
--
test_json_fail29
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail29.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail29.json",parse_json.is_parsed = False )
assert ("fail29.json", parse_json.is_parsed = False)
end
end
test_json_fail30
--
test_json_fail30
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail30.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail30.json",parse_json.is_parsed = False)
assert ("fail30.json", parse_json.is_parsed = False)
end
end
test_json_fail31
--
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail31.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail31.json",parse_json.is_parsed = False)
assert ("fail31.json", parse_json.is_parsed = False)
end
end
test_json_fail32
--
test_json_fail32
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail32.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail32.json",parse_json.is_parsed = False)
assert ("fail32.json", parse_json.is_parsed = False)
end
end
test_json_fail33
--
test_json_fail33
--
local
parse_json: like new_json_parser
do
if attached json_file_from ("fail33.json") as json_file then
parse_json := new_json_parser (json_file)
json_value := parse_json.parse_json
assert ("fail33.json",parse_json.is_parsed = False)
assert ("fail33.json", parse_json.is_parsed = False)
end
end
@@ -495,23 +484,22 @@ feature -- JSON_FROM_FILE
json_value: detachable JSON_VALUE
json_file_from (fn: STRING): detachable STRING
local
f: RAW_FILE
l_path: STRING
json_file_from (fn: STRING): detachable STRING
local
f: RAW_FILE
l_path: STRING
test_dir: STRING
i: INTEGER
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
-- Found json file
else
-- before EiffelStudio 7.3 , the current dir of autotest execution was not the parent dir of ecf but something like
-- ..json\test\autotest\test_suite\EIFGENs\test_suite\Testing\execution\TEST_JSON_SUITE.test_json_fail1\..\..\..\..\..\fail1.json
-- before EiffelStudio 7.3 , the current dir of autotest execution was not the parent dir of ecf but something like
-- ..json\test\autotest\test_suite\EIFGENs\test_suite\Testing\execution\TEST_JSON_SUITE.test_json_fail1\..\..\..\..\..\fail1.json
from
i := 5
until
@@ -536,9 +524,7 @@ feature -- JSON_FROM_FILE
create Result.make_parser (a_string)
end
invariant
file_reader /= Void
end