A docunit is extracted from the code-blocks of mdocs. Each mdoc can contains more than one docunit, and a single docunit can be made of more that a single code-block.
nitc :: DocUnit :: _test_file
The generated Nit source file that contains the unit-testnitc :: DocUnit :: _xml_classname
nitc :: DocUnit :: defaultinit
nitc :: DocUnit :: is_compiled=
Wastest_file
successfully compiled?
nitc :: DocUnit :: real_location
Compute the real location of a node on theast
based on mdoc.location
nitc :: DocUnit :: test_file=
The generated Nit source file that contains the unit-testnitc :: DocUnit :: xml_classname=
nitc $ DocUnit :: xml_classname
Theclassname
attribute of the XML format.
nitc :: UnitTest :: _error_location
The location where the error occurred, if it makes sense.nitc :: UnitTest :: _raw_output
The raw output of the execution (or compilation)nitc :: DocUnit :: _test_file
The generated Nit source file that contains the unit-testnitc :: DocUnit :: _xml_classname
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
nitc :: UnitTest :: defaultinit
core :: Object :: defaultinit
nitc :: DocUnit :: defaultinit
nitc :: UnitTest :: error_location
The location where the error occurred, if it makes sense.nitc :: UnitTest :: error_location=
The location where the error occurred, if it makes sense.nitc :: DocUnit :: is_compiled=
Wastest_file
successfully compiled?
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: native_class_name
The class name of the object in CString format.core :: Object :: output_class_name
Display class name on stdout (debug only).nitc :: UnitTest :: raw_output
The raw output of the execution (or compilation)nitc :: UnitTest :: raw_output=
The raw output of the execution (or compilation)nitc :: DocUnit :: real_location
Compute the real location of a node on theast
based on mdoc.location
nitc :: UnitTest :: status_tag
A colorful[OK]
or [KO]
.
nitc :: DocUnit :: test_file=
The generated Nit source file that contains the unit-testnitc :: UnitTest :: xml_classname
Theclassname
attribute of the XML format.
nitc :: DocUnit :: xml_classname=
# A unit-test extracted from some documentation.
#
# A docunit is extracted from the code-blocks of mdocs.
# Each mdoc can contains more than one docunit, and a single docunit can be made of more that a single code-block.
class DocUnit
super UnitTest
# The doc that contains self
var mdoc: MDoc
# The numbering of self in mdoc (starting with 0)
var number: Int
# The generated Nit source file that contains the unit-test
#
# Note that a same generated file can be used for multiple tests.
# See `test_arg` that is used to distinguish them
var test_file: nullable String = null
# Was `test_file` successfully compiled?
var is_compiled = false
# The command-line argument to use when executing the test, if any.
var test_arg: nullable Int = null
redef fun full_name do
var mentity = mdoc.original_mentity
if mentity != null then
var res = mentity.full_name
if number > 1 then
res += "#{number}"
end
return res
else
return xml_classname + "." + xml_name
end
end
# The text of the code to execute.
#
# This is the verbatim content on one, or more, code-blocks from `mdoc`
var block: String
# For each line in `block`, the associated line in the mdoc
#
# Is used to give precise locations
var lines = new Array[Int]
# For each line in `block`, the associated column in the mdoc
#
# Is used to give precise locations
var columns = new Array[Int]
# The location of the whole docunit.
#
# If `self` is made of multiple code-blocks, then the location
# starts at the first code-books and finish at the last one, thus includes anything between.
redef var location is lazy do
return new Location(mdoc.location.file, lines.first, lines.last+1, columns.first+1, 0)
end
# Compute the real location of a node on the `ast` based on `mdoc.location`
#
# The result is basically: ast_location + markdown location of the piece + mdoc.location
#
# The fun is that a single docunit can be made of various pieces of code blocks.
fun real_location(ast_location: Location): Location
do
var mdoc = self.mdoc
var res = new Location(mdoc.location.file,
lines[ast_location.line_start-1],
lines[ast_location.line_end-1],
columns[ast_location.line_start-1] + ast_location.column_start,
columns[ast_location.line_end-1] + ast_location.column_end)
return res
end
redef fun to_xml
do
var res = super
res.open("system-out").append(block)
return res
end
redef var xml_classname
redef var xml_name
end
src/testing/testing_doc.nit:460,1--548,3