# # / /
# # c -3- d -8- e
# #
-# var graph = new Graph[Node,WeigthedLink[Node]]
+# var graph = new Graph[Node,WeightedLink]
#
# var na = new Node(graph)
# var nb = new Node(graph)
# The user uses the provided query (item) to implements its own comparison
#
# var a = [1, 3, 2]
- # for q in a do q.res = q.a <=> q.b
- # assert print a == 123
+ # for q in a.sort_fa do q.res = q.a <=> q.b
+ # assert a == [1, 2, 3]
#
# Implements a sort by permutation.
fun sort_fa: ForAbuser[CompareQuery[E]]
# The abuse just ensures that the file is closed after the reading.
#
# for f in file_open("/etc/issue") do
-# print f.read_line
+# var l = f.read_line
+# print l
+# assert not l.is_empty
# end # f is automatically closed here
fun file_open(path: String): ForAbuser[IFStream]
do
# Is the HTML element a void element?
#
- # assert new HTMLTag("img").is_void == true
- # assert new HTMLTag("p").is_void == false
+ # assert (new HTMLTag("img")).is_void == true
+ # assert (new HTMLTag("p")).is_void == false
var is_void: Bool
init with_attrs(tag: String, attrs: Map[String, String]) do
end
# Append raw HTML to element
+ #
# var p = new HTMLTag("p")
# p.append("Hello")
- # p.add_raw_html("<bla/>")
- # p.html #- "<p>Hello<bla/></p>"
- # Note: the HTML in insered as it, no verification is done
+ # p.add_raw_html("<bla/>foo")
+ # assert p.write_to_string == "<p>Hello<bla/>foo</p>"
+ #
+ # Note: the HTML in insered as it, no verification is done.
fun add_raw_html(txt: String): HTMLTag do
add(new HTMLRaw(txt))
return self
#
# var i = [1,2,3,4,5].iterator
# assert i.head(2).to_a == [1,2]
- # i.to_a == [3,4,5]
+ # assert i.to_a == [3,4,5]
fun head(length: Int): Iterator[E]
do
return new PipeHead[E](self, length)
# Add each item of `coll`.
# var a = [1,2]
- # a.add_all [3..5]
+ # a.add_all([3..5])
# assert a.has(4) == true
# assert a.has(10) == false
fun add_all(coll: Collection[E]) do for i in coll do add(i)
# var x = new HashMap[String, Int]
# x["four"] = 4
# x.clear
- # x.keys.has("four") == false
+ # assert x.keys.has("four") == false
#
# ENSURE `is_empty`
fun clear is abstract
#
# class LnkTmpl
# super Template
-# var text: Template
+# var text: Streamable
# var title: nullable String
# var href: String
# redef fun rendering do
-# add """<a href="{{{href.html_escape}}}" """
-# if title != null then add """title="{{{title.html_escape}}}" """
+# add """<a href="{{{href.html_escape}}}""""
+# if title != null then add """ title="{{{title.html_escape}}}""""
# add ">"
# add text
# add "</a>"
# end
# # ...
# end
+# var l = new LnkTmpl
+# l.text = "hello world"
+# l.href = "hello.png"
+# assert l.write_to_string == """<a href="hello.png">hello world</a>"""
#
class Template
super Streamable