Standard me become privately imported when importing only modules privately.
Thus, some sub-modules cannot see standard.
This PR force standard to be always public if it is imported.
Close #909
Pull-Request: #913
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
# The node in the hiearchical structure for each element
private var nodes = new HashMap[E, DisjointSetNode]
+ # The number of subsets in the partition
+ #
+ # var s = new DisjointSet[Int]
+ # s.add_all([1,2,3,4,5])
+ # assert s.number_of_subsets == 5
+ # s.union_all([1,4,5])
+ # assert s.number_of_subsets == 3
+ # s.union(4,5)
+ # assert s.number_of_subsets == 3
+ var number_of_subsets: Int = 0
+
# Get the root node of an element
# require: `has(e)`
private fun find(e:E): DisjointSetNode
if nodes.has_key(e) then return
var ne = new DisjointSetNode
nodes[e] = ne
+ number_of_subsets += 1
end
# Are two elements in the same subset?
ne.rank = er+1
end
end
+ number_of_subsets -= 1
end
# Combine the subsets of all elements of `es`
# The lines of the current code block, empty is no current code block
var curblock = new Array[String]
+ # Count empty lines between code blocks
+ var empty_lines = 0
+
fun work(mdoc: MDoc): HTMLTag
do
var root = new HTMLTag("div")
# Is codeblock? Then just collect them
if indent >= 3 then
+ for i in [0..empty_lines[ do curblock.add("")
+ empty_lines = 0
# to allows 4 spaces including the one that follows the #
curblock.add(text)
continue
end
- # Was a codblock just before the current line ?
- close_codeblock(n or else root)
-
# fence opening
if text.substring(0,3) == "~~~" then
+ # Was a codblock just before the current line ?
+ close_codeblock(n or else root)
+
var l = 3
while l < text.length and text.chars[l] == '~' do l += 1
in_fence = text.substring(0, l)
if text.is_empty or indent < lastindent then
n = null
ul = null
- if text.is_empty then continue
+ if text.is_empty then
+ if not curblock.is_empty then empty_lines += 1
+ continue
+ end
end
+ # Was a codblock just before the current line ?
+ close_codeblock(n or else root)
+
# Special first word: new paragraph
if text.has_prefix("TODO") or text.has_prefix("FIXME") then
n = new HTMLTag("p")
do
# Is there a codeblock to manage?
if not curblock.is_empty then
+ empty_lines = 0
+
# determine the smalest indent
var minindent = -1
for text in curblock do
var indent = 0
while indent < text.length and text.chars[indent] == ' ' do indent += 1
+ # skip white lines
+ if indent >= text.length then continue
if minindent == -1 or indent < minindent then
minindent = indent
end
end
+ if minindent < 0 then minindent = 0
# Generate the text
var btext = new FlatBuffer
redef fun process_code(n: HTMLTag, text: String)
do
+ # Skip non-blocks
+ if n.tag != "pre" then return
+
# Try to parse it
var ast = toolcontext.parse_something(text)
toolcontext.modelbuilder.unit_entities += 1
cpt += 1
- var file = "{prefix}{cpt}.nit"
+ var file = "{prefix}-{cpt}.nit"
toolcontext.info("Execute doc-unit {tc.attrs["name"]} in {file}", 1)
test_nitunit.nit --no-color -o $WRITE
test_nitunit.nit --gen-suite --only-show
test_nitunit.nit --gen-suite --only-show --private
+test_nitunit2.nit -o $WRITE
-test_nitunit.nit:20,1--22,0: ERROR: nitunit.test_nitunit.test_nitunit::X.<class> (in .nitunit/test_nitunit2.nit): Runtime error: Assert failed (.nitunit/test_nitunit2.nit:5)
+test_nitunit.nit:20,1--22,0: ERROR: nitunit.test_nitunit.test_nitunit::X.<class> (in .nitunit/test_nitunit-2.nit): Runtime error: Assert failed (.nitunit/test_nitunit-2.nit:5)
-test_nitunit.nit:23,2--25,0: FAILURE: nitunit.test_nitunit.test_nitunit::X.test_nitunit::X::foo (in .nitunit/test_nitunit3.nit): .nitunit/test_nitunit3.nit:5,8--27: Error: Method or variable 'undefined_identifier' unknown in Sys.
+test_nitunit.nit:23,2--25,0: FAILURE: nitunit.test_nitunit.test_nitunit::X.test_nitunit::X::foo (in .nitunit/test_nitunit-3.nit): .nitunit/test_nitunit-3.nit:5,8--27: Error: Method or variable 'undefined_identifier' unknown in Sys.
test_test_nitunit.nit:36,2--40,4: ERROR: test_foo1 (in file .nitunit/test_test_nitunit_TestX_test_foo1.nit): Runtime error: Assert failed (test_test_nitunit.nit:39)
Class suites: 1; Test Cases: 3; Failures: 1
<testsuites><testsuite package="test_nitunit"><testcase classname="nitunit.test_nitunit.<module>" name="<module>"><system-err></system-err><system-out>assert true
</system-out></testcase><testcase classname="nitunit.test_nitunit.test_nitunit::X" name="<class>"><system-err></system-err><system-out>assert false
-</system-out><error message="Runtime error: Assert failed (.nitunit/test_nitunit2.nit:5)
+</system-out><error message="Runtime error: Assert failed (.nitunit/test_nitunit-2.nit:5)
"></error></testcase><testcase classname="nitunit.test_nitunit.test_nitunit::X" name="test_nitunit::X::foo"><system-err></system-err><system-out>assert undefined_identifier
-</system-out><failure message=".nitunit/test_nitunit3.nit:5,8--27: Error: Method or variable 'undefined_identifier' unknown in Sys.
+</system-out><failure message=".nitunit/test_nitunit-3.nit:5,8--27: Error: Method or variable 'undefined_identifier' unknown in Sys.
"></failure></testcase></testsuite><testsuite package="test_test_nitunit"><testcase classname="nitunit.test_test_nitunit.test_test_nitunit::TestX" name="test_test_nitunit::TestX::test_foo"><system-err></system-err><system-out>out</system-out></testcase><testcase classname="nitunit.test_test_nitunit.test_test_nitunit::TestX" name="test_test_nitunit::TestX::test_foo1"><system-err></system-err><system-out>out</system-out><error message="Runtime error: Assert failed (test_test_nitunit.nit:39)
"></error></testcase><testcase classname="nitunit.test_test_nitunit.test_test_nitunit::TestX" name="test_test_nitunit::TestX::test_foo2"><system-err></system-err><system-out>out</system-out></testcase></testsuite></testsuites>
\ No newline at end of file
--- /dev/null
+DocUnits:
+DocUnits Success
+Entities: 4; Documented ones: 3; With nitunits: 3; Failures: 0
+
+TestSuites:
+No test cases found
+Class suites: 0; Test Cases: 0; Failures: 0
+<testsuites><testsuite package="test_nitunit2"><testcase classname="nitunit.test_nitunit2.standard::kernel::Object" name="test_nitunit2::Object::foo1"><system-err></system-err><system-out>if true then
+
+ assert true
+
+end
+</system-out></testcase><testcase classname="nitunit.test_nitunit2.standard::kernel::Object" name="test_nitunit2::Object::bar2"><system-err></system-err><system-out>if true then
+
+ assert true
+
+end
+</system-out></testcase><testcase classname="nitunit.test_nitunit2.standard::kernel::Object" name="test_nitunit2::Object::foo3"><system-err></system-err><system-out>var a = 1
+assert a == 1
+assert a == 1
+</system-out></testcase></testsuite><testsuite></testsuite></testsuites>
\ No newline at end of file
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# a fence unit
+#
+# ~~~~
+# if true then
+#
+# assert true
+#
+# end
+# ~~~~
+fun foo1 do end
+
+# a block unit
+#
+# if true then
+#
+# assert true
+#
+# end
+fun bar2 do end
+
+# a context continuation
+#
+# var a = 1
+# assert a == 1
+#
+# bla bla
+#
+# assert a == 1
+fun foo3 do end