Merge: doc: fixed some typos and other misc. corrections
[nit.git] / tests / sav / nitpretty_args25.res
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 class Foo
16         fun bar: Bool do return true
17
18         fun foo(other: Foo): Foo
19         do
20                 if other.bar then
21                         return other
22                 else
23                         return self
24                 end
25         end
26
27         fun baz: Int do
28                 var nb = 0
29
30                 while nb < 10 do
31                         print nb
32                         nb += 1
33                 end # 1
34
35                 return nb
36         end
37
38         fun gaz: Int
39         do
40                 if bar then # 3
41                         return 1
42                 else
43                         return -1 # 4
44                 end
45         end
46 end
47
48 class Test[E]
49         var heap: ArrayHeap[E]
50         init to(comparator: Comparator[E]) do heap = new ArrayHeap[E](comparator)
51
52         init from(comparator: Comparator[E], items: Collection[E]) do
53                 heap = new ArrayHeap[E].from(comparator, items.to_a)
54         end
55
56         fun count(k: E): Int do
57                 if heap.has(k) then
58                         return 1
59                 else
60                         return 0
61                 end
62         end
63
64         fun node_at_idx(i: Int, k: E) do
65                 while heap != null do
66                         if heap.is_empty or i == k then # FIXME prefilter because the compiler is not smart enought yet
67                                 break
68                         end
69                 end
70         end
71
72         fun save_those_nodes(nodes: Collection[Object]) do
73                 for node in nodes do count(node)
74         end
75 end
76
77 fun foo do
78         if last_slash > 0 then
79                 return substring(last_slash + 1, length)
80         else
81                 return null
82         end
83 end
84
85 print "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam tincidunt sapien et velit fringilla varius at non eros. Nunc ut ultricies metus, sit amet lacinia felis. Donec in facilisis neque, non laoreet nibh. Etiam nec purus eu orci congue iaculis eu quis lorem. Ut et blandit erat. Cras fermentum pellentesque ante, ut dapibus ipsum placerat sit amet. Vivamus pharetra, sem vitae consequat venenatis, diam risus placerat est, sed hendrerit purus justo vitae lectus. In id quam mattis, rutrum augue eu, vehicula ipsum. Nulla nec egestas turpis, nec ullamcorper odio. Pellentesque vitae arcu justo. Aliquam sed pharetra lacus."
86
87 var lorem = "lorem"
88 var ipsum = "ipsum" # for fun
89
90 print "We also need to handle super strings: {lorem} {ipsum} dolor sit amet, consectetur adipiscing elit. Aliquam tincidunt sapien et velit fringilla varius at non eros. Nunc ut ultricies metus, sit amet lacinia felis. Donec in facilisis neque, non laoreet nibh. Etiam nec purus eu orci congue iaculis eu quis {lorem}. Ut et blandit erat. Cras fermentum pellentesque ante, ut dapibus {ipsum} placerat sit amet. Vivamus pharetra, sem vitae consequat venenatis, diam risus placerat est, sed hendrerit purus justo vitae lectus. In id quam mattis, rutrum augue eu, vehicula ipsum. Nulla nec egestas turpis, nec ullamcorper odio. Pellentesque vitae arcu justo. Aliquam sed pharetra lacus." # ending
91
92 var title = "title"
93 var links = new Array[String] # why not?
94
95 var body = """
96 <!DOCTYPE html>
97 <head>
98         <meta charset="utf-8">
99         <meta http-equiv="X-UA-Compatible" content="IE=edge">
100         <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
101         <title>{{{title}}}</title>
102 </head>
103 <body>
104         <div class="container">
105                 <h1>{{{title}}}</h1>
106                 <ul>
107                         <li>{{{links.join("</li>\n\t\t\t<li>")}}}</li>
108                 </ul>
109         </div>
110 </body>
111 </html>"""