From: Jean Privat Date: Thu, 24 Apr 2014 03:41:24 +0000 (-0400) Subject: lib: fix some nitunit tests, thanks to the new features of the tool X-Git-Tag: v0.6.6~105^2~1 X-Git-Url: http://nitlanguage.org lib: fix some nitunit tests, thanks to the new features of the tool Signed-off-by: Jean Privat --- diff --git a/lib/a_star.nit b/lib/a_star.nit index 32a5f8c..2f18583 100644 --- a/lib/a_star.nit +++ b/lib/a_star.nit @@ -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) diff --git a/lib/for_abuse.nit b/lib/for_abuse.nit index a0fb743..40cb1bf 100644 --- a/lib/for_abuse.nit +++ b/lib/for_abuse.nit @@ -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 diff --git a/lib/html.nit b/lib/html.nit index f49ba3a..d6c8092 100644 --- a/lib/html.nit +++ b/lib/html.nit @@ -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("") - # p.html #- "

Hello

" - # Note: the HTML in insered as it, no verification is done + # p.add_raw_html("foo") + # assert p.write_to_string == "

Hellofoo

" + # + # 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 diff --git a/lib/pipeline.nit b/lib/pipeline.nit index 055823f..0c422ed 100644 --- a/lib/pipeline.nit +++ b/lib/pipeline.nit @@ -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) diff --git a/lib/standard/collection/abstract_collection.nit b/lib/standard/collection/abstract_collection.nit index dbed6d6..a08f7d4 100644 --- a/lib/standard/collection/abstract_collection.nit +++ b/lib/standard/collection/abstract_collection.nit @@ -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 diff --git a/lib/template.nit b/lib/template.nit index 9608f49..d254c24 100644 --- a/lib/template.nit +++ b/lib/template.nit @@ -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 """" # add text # add "" # end # # ... # end +# var l = new LnkTmpl +# l.text = "hello world" +# l.href = "hello.png" +# assert l.write_to_string == """hello world""" # class Template super Streamable