lib: fix some nitunit tests, thanks to the new features of the tool
authorJean Privat <jean@pryen.org>
Thu, 24 Apr 2014 03:41:24 +0000 (23:41 -0400)
committerJean Privat <jean@pryen.org>
Fri, 25 Apr 2014 00:45:02 +0000 (20:45 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

lib/a_star.nit
lib/for_abuse.nit
lib/html.nit
lib/pipeline.nit
lib/standard/collection/abstract_collection.nit
lib/template.nit

index 32a5f8c..2f18583 100644 (file)
@@ -29,7 +29,7 @@
 # #  /     /
 # # 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)
index a0fb743..40cb1bf 100644 (file)
@@ -141,8 +141,8 @@ redef class Array[E]
        # 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]]
@@ -157,7 +157,9 @@ end
 # 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
index f49ba3a..d6c8092 100644 (file)
@@ -96,8 +96,8 @@ class HTMLTag
 
        # 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
@@ -224,11 +224,13 @@ class HTMLTag
        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
index 055823f..0c422ed 100644 (file)
@@ -99,7 +99,7 @@ redef interface Iterator[E]
        #
        #     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)
index dbed6d6..a08f7d4 100644 (file)
@@ -249,7 +249,7 @@ interface SimpleCollection[E]
 
        # 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)
@@ -494,7 +494,7 @@ interface Map[K: Object, E]
        #     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
index 9608f49..d254c24 100644 (file)
@@ -67,18 +67,22 @@ module template
 #
 #     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