Merge: tests: Test result update for `curl_http`
[nit.git] / tests / sav / nitpretty_args60.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                 while nb < 10 do
30                         print nb
31                         nb += 1
32                 end # 1
33                 return nb
34         end
35
36         fun gaz: Int
37         do
38                 if bar then # 3
39                         return 1
40                 else
41                         return -1 # 4
42                 end
43         end
44 end
45
46 class Test[E]
47         var heap: ArrayHeap[E]
48
49         init to(comparator: Comparator[E]) do heap = new ArrayHeap[E](comparator)
50
51         init from(comparator: Comparator[E], items: Collection[E]) do
52                 heap = new ArrayHeap[E].from(comparator, items.to_a)
53         end
54
55         fun count(k: E): Int do
56                 if heap.has(k) then
57                         return 1
58                 else
59                         return 0
60                 end
61         end
62
63         fun node_at_idx(i: Int, k: E) do
64                 while heap != null do
65                         if heap.is_empty or i == k then # FIXME prefilter because the compiler is not smart enought yet
66                                 break
67                         end
68                 end
69         end
70
71         fun save_those_nodes(nodes: Collection[Object]) do
72                 for node in nodes do count(node)
73         end
74 end
75
76 fun foo do
77         if last_slash > 0 then
78                 return substring(last_slash + 1, length)
79         else
80                 return null
81         end
82 end
83
84 print "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam tincidun" +
85         "t sapien et velit fringilla varius at non eros. Nunc ut ultricies metus, sit a" +
86         "met lacinia felis. Donec in facilisis neque, non laoreet nibh. Etiam nec purus" +
87         " eu orci congue iaculis eu quis lorem. Ut et blandit erat. Cras fermentum pell" +
88         "entesque ante, ut dapibus ipsum placerat sit amet. Vivamus pharetra, sem vitae" +
89         " consequat venenatis, diam risus placerat est, sed hendrerit purus justo vitae" +
90         " lectus. In id quam mattis, rutrum augue eu, vehicula ipsum. Nulla nec egestas" +
91         " turpis, nec ullamcorper odio. Pellentesque vitae arcu justo. Aliquam sed phar" +
92         "etra lacus."
93
94 var lorem = "lorem"
95 var ipsum = "ipsum" # for fun
96
97 print "We also need to handle super strings: {lorem} {ipsum} dolor sit amet, con" +
98         "sectetur adipiscing elit. Aliquam tincidunt sapien et velit fringilla varius a" +
99         "t non eros. Nunc ut ultricies metus, sit amet lacinia felis. Donec in facilisi" +
100         "s neque, non laoreet nibh. Etiam nec purus eu orci congue iaculis eu quis {lorem}" +
101         ". Ut et blandit erat. Cras fermentum pellentesque ante, ut dapibus {ipsum} pla" +
102         "cerat sit amet. Vivamus pharetra, sem vitae consequat venenatis, diam risus pl" +
103         "acerat est, sed hendrerit purus justo vitae lectus. In id quam mattis, rutrum " +
104         "augue eu, vehicula ipsum. Nulla nec egestas turpis, nec ullamcorper odio. Pell" +
105         "entesque vitae arcu justo. Aliquam sed pharetra lacus." # ending
106
107 var title = "title"
108 var links = new Array[String] # why not?
109
110 var body = """
111 <!DOCTYPE html>
112 <head>
113         <meta charset="utf-8">
114         <meta http-equiv="X-UA-Compatible" content="IE=edge">
115         <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
116         <title>{{{title}}}</title>
117 </head>
118 <body>
119         <div class="container">
120                 <h1>{{{title}}}</h1>
121                 <ul>
122                         <li>{{{links.join("</li>\n\t\t\t<li>")}}}</li>
123                 </ul>
124         </div>
125 </body>
126 </html>"""
127