tests: add tests for nitpretty
authorAlexandre Terrasa <alexandre@moz-code.org>
Mon, 4 Aug 2014 00:08:23 +0000 (20:08 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Wed, 3 Sep 2014 18:35:49 +0000 (14:35 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

56 files changed:
tests/nitpretty.args [new file with mode: 0644]
tests/sav/nitpretty.res [new file with mode: 0644]
tests/sav/nitpretty_args1.res [new file with mode: 0644]
tests/sav/nitpretty_args10.res [new file with mode: 0644]
tests/sav/nitpretty_args11.res [new file with mode: 0644]
tests/sav/nitpretty_args12.res [new file with mode: 0644]
tests/sav/nitpretty_args13.res [new file with mode: 0644]
tests/sav/nitpretty_args14.res [new file with mode: 0644]
tests/sav/nitpretty_args15.res [new file with mode: 0644]
tests/sav/nitpretty_args16.res [new file with mode: 0644]
tests/sav/nitpretty_args17.res [new file with mode: 0644]
tests/sav/nitpretty_args18.res [new file with mode: 0644]
tests/sav/nitpretty_args19.res [new file with mode: 0644]
tests/sav/nitpretty_args2.res [new file with mode: 0644]
tests/sav/nitpretty_args20.res [new file with mode: 0644]
tests/sav/nitpretty_args21.res [new file with mode: 0644]
tests/sav/nitpretty_args22.res [new file with mode: 0644]
tests/sav/nitpretty_args23.res [new file with mode: 0644]
tests/sav/nitpretty_args24.res [new file with mode: 0644]
tests/sav/nitpretty_args25.res [new file with mode: 0644]
tests/sav/nitpretty_args26.res [new file with mode: 0644]
tests/sav/nitpretty_args27.res [new file with mode: 0644]
tests/sav/nitpretty_args3.res [new file with mode: 0644]
tests/sav/nitpretty_args4.res [new file with mode: 0644]
tests/sav/nitpretty_args5.res [new file with mode: 0644]
tests/sav/nitpretty_args6.res [new file with mode: 0644]
tests/sav/nitpretty_args7.res [new file with mode: 0644]
tests/sav/nitpretty_args8.res [new file with mode: 0644]
tests/sav/nitpretty_args9.res [new file with mode: 0644]
tests/test_pretty/test_annot1.nit [new file with mode: 0644]
tests/test_pretty/test_attr1.nit [new file with mode: 0644]
tests/test_pretty/test_attr2.nit [new file with mode: 0644]
tests/test_pretty/test_call1.nit [new file with mode: 0644]
tests/test_pretty/test_call2.nit [new file with mode: 0644]
tests/test_pretty/test_class1.nit [new file with mode: 0644]
tests/test_pretty/test_class2.nit [new file with mode: 0644]
tests/test_pretty/test_class3.nit [new file with mode: 0644]
tests/test_pretty/test_comments1.nit [new file with mode: 0644]
tests/test_pretty/test_extern1.nit [new file with mode: 0644]
tests/test_pretty/test_if1.nit [new file with mode: 0644]
tests/test_pretty/test_if2.nit [new file with mode: 0644]
tests/test_pretty/test_if3.nit [new file with mode: 0644]
tests/test_pretty/test_indent1.nit [new file with mode: 0644]
tests/test_pretty/test_loop1.nit [new file with mode: 0644]
tests/test_pretty/test_loop2.nit [new file with mode: 0644]
tests/test_pretty/test_loop3.nit [new file with mode: 0644]
tests/test_pretty/test_mod1.nit [new file with mode: 0644]
tests/test_pretty/test_mod2.nit [new file with mode: 0644]
tests/test_pretty/test_mod3.nit [new file with mode: 0644]
tests/test_pretty/test_op1.nit [new file with mode: 0644]
tests/test_pretty/test_op2.nit [new file with mode: 0644]
tests/test_pretty/test_op3.nit [new file with mode: 0644]
tests/test_pretty/test_prims1.nit [new file with mode: 0644]
tests/test_pretty/test_prop1.nit [new file with mode: 0644]
tests/test_pretty/test_prop2.nit [new file with mode: 0644]
tests/test_pretty/test_prop3.nit [new file with mode: 0644]

diff --git a/tests/nitpretty.args b/tests/nitpretty.args
new file mode 100644 (file)
index 0000000..61b0157
--- /dev/null
@@ -0,0 +1,27 @@
+test_pretty/test_mod1.nit
+test_pretty/test_mod2.nit
+test_pretty/test_mod3.nit
+test_pretty/test_class1.nit
+test_pretty/test_class2.nit
+test_pretty/test_class3.nit
+test_pretty/test_prop1.nit
+test_pretty/test_prop2.nit
+test_pretty/test_prop3.nit
+test_pretty/test_loop1.nit
+test_pretty/test_loop2.nit
+test_pretty/test_loop3.nit
+test_pretty/test_call1.nit
+test_pretty/test_call2.nit
+test_pretty/test_if1.nit
+test_pretty/test_if2.nit
+test_pretty/test_if3.nit
+test_pretty/test_op1.nit
+test_pretty/test_op2.nit
+test_pretty/test_op3.nit
+test_pretty/test_extern1.nit
+test_pretty/test_attr1.nit
+test_pretty/test_attr2.nit
+test_pretty/test_comments1.nit
+test_pretty/test_indent1.nit
+test_pretty/test_prims1.nit
+test_pretty/test_annot1.nit
diff --git a/tests/sav/nitpretty.res b/tests/sav/nitpretty.res
new file mode 100644 (file)
index 0000000..0b02ffb
--- /dev/null
@@ -0,0 +1,3 @@
+Usage: nitpretty [OPTION]... <file.nit>
+Pretty print Nit code from Nit source files.
+Use --help for help
diff --git a/tests/sav/nitpretty_args1.res b/tests/sav/nitpretty_args1.res
new file mode 100644 (file)
index 0000000..f9f0615
--- /dev/null
@@ -0,0 +1,15 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# An empty module
diff --git a/tests/sav/nitpretty_args10.res b/tests/sav/nitpretty_args10.res
new file mode 100644 (file)
index 0000000..3868546
--- /dev/null
@@ -0,0 +1,33 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+var a = 1
+var b = 2
+
+while a != b do # comment 1
+       # comment 2
+       var tmp = a
+       a = b
+       b = tmp
+       # comment 3
+end
+
+# comment 4
+while a != b do a = b # comment 5
+
+while a != b do
+       # comment 6
+end # comment 7
+
+# end
diff --git a/tests/sav/nitpretty_args11.res b/tests/sav/nitpretty_args11.res
new file mode 100644 (file)
index 0000000..57d2648
--- /dev/null
@@ -0,0 +1,42 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+var a = 0
+var b = 2
+
+do # comment 1
+       # comment 2
+       var tmp = a
+       a = b
+       b = tmp
+       # comment 3
+end
+
+# comment 4
+do a = b # comment 5
+
+do
+       # comment 6
+end
+
+if a > b then loop print a # test
+if a > b then loop print a
+if a > b then loop print a
+
+if a > b then
+       loop
+               # comment 7
+               print a
+       end
+end
diff --git a/tests/sav/nitpretty_args12.res b/tests/sav/nitpretty_args12.res
new file mode 100644 (file)
index 0000000..0135aa1
--- /dev/null
@@ -0,0 +1,27 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+var a = 0
+
+for i in [1, 2, 3] do # comment 1
+       # comment 2
+       a += i
+end
+
+# comment 4
+for i in [1..3] do a += i # comment 5
+
+for i in [1..3[ do
+       # comment 6
+end
diff --git a/tests/sav/nitpretty_args13.res b/tests/sav/nitpretty_args13.res
new file mode 100644 (file)
index 0000000..eaf7f56
--- /dev/null
@@ -0,0 +1,34 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+class A
+       fun foo do end
+       fun bar(a: Int): Int do return 1
+       fun baz(a, b: Int) do end
+       fun gaz(a: Int, b: Float...) do end
+end
+
+fun top1 do end
+
+fun top2(a: Int) do end
+
+# comment 1
+var a = new A # comment 2
+a.foo # comment 3
+a.bar 1 # comment 4
+a.baz(1, 2) # comment 5
+top1 # comment 6
+top2 10 # comment 7
+print 10 # comment 8
+var b = a.bar(1)
diff --git a/tests/sav/nitpretty_args14.res b/tests/sav/nitpretty_args14.res
new file mode 100644 (file)
index 0000000..e2f4e9a
--- /dev/null
@@ -0,0 +1,37 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+class A
+       var attr: Int
+       fun foo1=(i: Int) do end
+       fun foo2=(i, j: Int) do end
+       fun [](a: Int): Int is abstract
+       fun []=(a, b: Int) do end
+end
+
+class B
+       fun [](a, b: Int): Int is abstract
+       fun []=(a, b, c: Int) do end
+end
+
+# comment 1
+var a = new A(10) # comment 2
+a.foo1 = 10 # comment 3
+a.foo2(1) = 10 # comment 4
+print a[1] # comment 5
+a[1] = 2 # comment 6
+a[2] += 3 # comment 7
+var b = new B
+print b[1, 2]
+b[1, 2] = 10
diff --git a/tests/sav/nitpretty_args15.res b/tests/sav/nitpretty_args15.res
new file mode 100644 (file)
index 0000000..d2a5ee1
--- /dev/null
@@ -0,0 +1,49 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+var a = 1
+var b = 2
+if a == b then a = b
+
+if a != b then
+       a = b
+       a = b
+end
+
+if a > b then
+       b = a
+       a = b
+else
+       a = b
+       a = b
+end
+
+if a < b then
+       a = b
+       a = b
+else if a == b then
+       b = a
+       a = b
+end
+
+if a < b then
+       a = b
+       a = b
+else if a == b then
+       b = b
+       a = b
+else
+       a = b
+       a = b
+end
diff --git a/tests/sav/nitpretty_args16.res b/tests/sav/nitpretty_args16.res
new file mode 100644 (file)
index 0000000..46efbce
--- /dev/null
@@ -0,0 +1,81 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# comment
+
+var a = 1 # comment
+# comment
+var b = 2 # comment
+# comment
+if a == b then a = b # comment
+
+# comment
+if a != b then # comment
+       # comment
+       a = b # comment
+       # comment
+       a = b # comment
+       # comment
+end # comment
+
+# comment
+if a > b then # comment
+       # comment
+       b = a # comment
+       # comment
+       a = b # comment
+       # comment
+else # comment
+       # comment
+       a = b # comment
+       # comment
+       a = b # comment
+       # comment
+end # comment
+
+# comment
+if a < b then # comment
+       # comment
+       a = b # comment
+       # comment
+       a = b # comment
+       # comment
+else if a == b then # comment
+       # comment
+       b = a # comment
+       # comment
+       a = b # comment
+       # comment
+end # comment
+
+# comment
+if a < b then # comment
+       # comment
+       a = b # comment
+       # comment
+       a = b # comment
+       # comment
+else if a == b then # comment
+       # comment
+       b = b # comment
+       # comment
+       a = b # comment
+       # comment
+else # comment
+       # comment
+       a = b # comment
+       # comment
+       a = b # comment
+       # comment
+end # comment
diff --git a/tests/sav/nitpretty_args17.res b/tests/sav/nitpretty_args17.res
new file mode 100644 (file)
index 0000000..e5aec78
--- /dev/null
@@ -0,0 +1,55 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+var a = 1
+var b = 2
+
+# 0
+if a == b then # 1
+       # 2
+else # 3
+       # 4
+end # 5
+
+if a == b then print a # printing a
+
+if a == b then
+       print a # printing a
+end
+
+if a == b then print a # end
+if a == b then a = b
+if a == b then end
+if a == b then end
+if a != b then a = b
+
+if a > b then
+       a = b
+else
+       a = b
+end
+
+if a < b then
+       a = b
+else if a == b then
+       a = b
+end
+
+if a < b then
+       a = b
+else if a == b then
+       a = b
+else
+       a = b
+end
diff --git a/tests/sav/nitpretty_args18.res b/tests/sav/nitpretty_args18.res
new file mode 100644 (file)
index 0000000..7b25cdb
--- /dev/null
@@ -0,0 +1,20 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+var a: nullable Int = 1
+var b: nullable Int = a.as(Int)
+var c: nullable Int = a.as(not null)
+assert c isa Int
+assert test1: c isa Int
+assert test2: c isa Int else abort
diff --git a/tests/sav/nitpretty_args19.res b/tests/sav/nitpretty_args19.res
new file mode 100644 (file)
index 0000000..f53462a
--- /dev/null
@@ -0,0 +1,28 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+var a = 1
+var b = 2
+assert a == 2
+assert not a < 2 # comment 1
+assert a > 2 and b >= 2
+assert b != 2 or a <= 2
+assert b != null # comment 2
+# comment 3
+print a + b
+print a - b # comment 4
+print a * b
+print a / b
+print a % b
+print -a # comment 5
diff --git a/tests/sav/nitpretty_args2.res b/tests/sav/nitpretty_args2.res
new file mode 100644 (file)
index 0000000..7afcc94
--- /dev/null
@@ -0,0 +1,23 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Testing only imports
+
+# Module comment
+module test_mod2 # second comment
+
+import standard::kernel
+#import standard::string
+import template # no need for string
+# import standard
diff --git a/tests/sav/nitpretty_args20.res b/tests/sav/nitpretty_args20.res
new file mode 100644 (file)
index 0000000..9d59193
--- /dev/null
@@ -0,0 +1,25 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+var a = 1
+var b = 2
+assert not a < 2 and (a == b or a > b) # comment 1
+assert not a < 2 and (a == b or ((a > b) or a <= b))
+assert (a > 2 and b >= 2)
+assert (b >= 2)
+# comment 3
+var c = a + (b - a)
+var d = (a - b) + c # comment 4
+var e = (-a) # comment 5
+var f = -(a - c)
diff --git a/tests/sav/nitpretty_args21.res b/tests/sav/nitpretty_args21.res
new file mode 100644 (file)
index 0000000..9b58418
--- /dev/null
@@ -0,0 +1,87 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import end
+intrude import standard::kernel
+private import standard::string
+
+`{`}
+
+`{
+#ifdef truc
+       #undef truc
+#endif
+`}
+
+in "C headers" `{
+       #include <errno.h>
+`}
+
+fun err: Int is extern `{ return 1; `}
+
+fun errno: Int is extern `{
+       return errno;
+`}
+
+fun errnoooooooooooooooooooooooooooooooooooooooooooooooooooooooooo: Int is extern `{
+        return errno;
+`}
+
+private class A
+       var my_attr = 1234
+
+       fun baz(msg: String) import String.length, String.to_cstring, my_attr, my_attr= `{
+               char *c_msg;
+               int msg_len;
+
+               /* String_to_cstring isa a allback to msg.to_cstring */
+               c_msg = String_to_cstring( msg );
+
+               /* String_length is a callback to msg.length */
+               msg_len = String_length( msg );
+
+               printf( "received msg: %s, of length = %d\n", c_msg, msg_len );
+
+               /* A_my_attr is a callback to the getter of self.my_attr */
+               printf( "old attr %d\n", A_my_attr(recv) );
+
+               if(chose)
+                       truc;
+               else
+                       chose;
+
+               /* A_my_attr is a callback to the setter of self.my_attr= */
+               A_my_attr__assign( recv, msg_len );
+       `}
+end
+
+extern class TimeT `{time_t`}
+       new `{ return time(NULL); `}
+       new from_i(i: Int) `{ return i; `}
+       fun update `{ time(&recv); `}
+
+       fun ctime: String import NativeString.to_s_with_copy `{
+               return NativeString_to_s_with_copy( ctime(&recv) );
+       `}
+
+       # Difference in secondes from start (self if the end time)
+       fun difftime(start: TimeT): Float `{ return difftime(recv, start); `}
+
+       private fun intern_poll(in_fds: Array[Int], out_fds: Array[Int]): nullable Int is extern import
+               Array[Int].length, Array[Int].[], Int.as(nullable Int) `{`}
+end
+
+fun address_is_null: Bool is extern "address_is_null"
+
+fun free `{ free(recv); `}
diff --git a/tests/sav/nitpretty_args22.res b/tests/sav/nitpretty_args22.res
new file mode 100644 (file)
index 0000000..b04cd1d
--- /dev/null
@@ -0,0 +1,29 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+class A
+       var a: Int # comment
+       private var b: nullable Int # happy
+       protected var c = 10 # ending
+       var d: Int = 10
+
+       # Test test...
+       var e: Int writable
+
+       var f: Int protected writable
+
+       # Adoc
+       var k: Int protected writable = 10
+       # more comments
+end # end
diff --git a/tests/sav/nitpretty_args23.res b/tests/sav/nitpretty_args23.res
new file mode 100644 (file)
index 0000000..5b727f7
--- /dev/null
@@ -0,0 +1,24 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+class Foo
+       var _a: Int
+       private var _b: nullable Int
+       protected var _c = 10
+       var _d: Int = 10
+end
+
+var foo = new Foo(1, 2)
+print foo._a
+foo._a = 10
diff --git a/tests/sav/nitpretty_args24.res b/tests/sav/nitpretty_args24.res
new file mode 100644 (file)
index 0000000..79ab858
--- /dev/null
@@ -0,0 +1,71 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# toplevel comment
+
+# block
+# block
+# block
+
+# Adoc1
+class A # ending comments
+       super Object
+       # super Int
+       super String
+
+       # super Truc
+
+       # inclass comments
+       # comm
+       #    ented
+       #      blocks
+
+       # Adoc2
+       fun foo do
+
+               # comment
+
+               var truc
+
+               # comment
+               # comment
+
+               # comment
+
+               var chose
+               # comment
+       end
+
+       # comm
+       #    ented
+       #      blocks
+
+       fun bar do end
+       fun baz do end
+       # comment before end
+end # ending comments
+
+# comm
+#    ented
+#      blocks
+
+abstract class B # comment
+end
+
+abstract class C end
+
+abstract class B # comment 2
+end
+
+abstract class C end
diff --git a/tests/sav/nitpretty_args25.res b/tests/sav/nitpretty_args25.res
new file mode 100644 (file)
index 0000000..6638706
--- /dev/null
@@ -0,0 +1,123 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+class Foo
+       fun bar: Bool do return true
+
+       fun foo(other: Foo): Foo do
+               if other.bar then
+                       return other
+               else
+                       return self
+               end
+       end
+
+       fun baz: Int do
+               var nb = 0
+
+               while nb < 10 do
+                       print nb
+                       nb += 1
+               end # 1
+
+               return nb
+       end
+
+       fun gaz: Int do
+               if bar then # 3
+                       return 1
+               else
+                       return -1 # 4
+               end
+       end
+end
+
+class Test[E]
+       var heap: ArrayHeap[E]
+       init to(comparator: Comparator[E]) do heap = new ArrayHeap[E](comparator)
+
+       init from(comparator: Comparator[E], items: Collection[E]) do
+               heap = new ArrayHeap[E].from(comparator, items.to_a)
+       end
+
+       fun count(k: E): Int do
+               if heap.has(k) then
+                       return 1
+               else
+                       return 0
+               end
+       end
+
+       fun node_at_idx(i: Int, k: E) do
+               while heap != null do
+                       if heap.is_empty or i == k then # FIXME prefilter because the compiler is not smart enought yet
+                               break
+                       end
+               end
+       end
+
+       fun save_those_nodes(nodes: Collection[Object]) do for node in nodes do count(node)
+end
+
+fun foo do
+       if last_slash > 0 then
+               return substring(last_slash + 1, length)
+       else
+               return null
+       end
+end
+
+print "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam tincidun" +
+       "t sapien et velit fringilla varius at non eros. Nunc ut ultricies metus, sit a" +
+       "met 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 pell" +
+       "entesque 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 phar" +
+       "etra lacus."
+
+var lorem = "lorem"
+var ipsum = "ipsum" # for fun
+
+print "We also need to handle super strings: {lorem} {ipsum} dolor sit amet, con" +
+       "sectetur adipiscing elit. Aliquam tincidunt sapien et velit fringilla varius a" +
+       "t non eros. Nunc ut ultricies metus, sit amet lacinia felis. Donec in facilisi" +
+       "s 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} pla" +
+       "cerat sit amet. Vivamus pharetra, sem vitae consequat venenatis, diam risus pl" +
+       "acerat est, sed hendrerit purus justo vitae lectus. In id quam mattis, rutrum " +
+       "augue eu, vehicula ipsum. Nulla nec egestas turpis, nec ullamcorper odio. Pell" +
+       "entesque vitae arcu justo. Aliquam sed pharetra lacus." # ending
+
+var title = "title"
+var links = new Array[String] # why not?
+
+var body = """
+<!DOCTYPE html>
+<head>
+       <meta charset="utf-8">
+       <meta http-equiv="X-UA-Compatible" content="IE=edge">
+       <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
+       <title>{{{title}}}</title>
+</head>
+<body>
+       <div class="container">
+               <h1>{{{title}}}</h1>
+               <ul>
+                       <li>{{{links.join("</li>\n\t\t\t<li>")}}}</li>
+               </ul>
+       </div>
+</body>
+</html>"""
diff --git a/tests/sav/nitpretty_args26.res b/tests/sav/nitpretty_args26.res
new file mode 100644 (file)
index 0000000..5bafc26
--- /dev/null
@@ -0,0 +1,43 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# prims
+
+var a = true
+var b = false
+var c = 10
+var d = -10
+var e = 1.12
+var f = -1.12
+var n = 'a'
+var o = null
+var p = 0x12345678
+
+# strings
+
+var g = "test"
+var h1 = "Hello {g}"
+var h2 = "Hello \"{g}\" Hello"
+var h3 = "Hello {g}"
+var m = """
+bla
+       bla
+
+bla"""
+
+# arrays
+
+var j = [1, 2, 3]
+var k = [1..2[
+var l = [1..2]
diff --git a/tests/sav/nitpretty_args27.res b/tests/sav/nitpretty_args27.res
new file mode 100644 (file)
index 0000000..0406b29
--- /dev/null
@@ -0,0 +1,45 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+module test_annot1 is platform("android")
+
+class A
+       fun foo is a, b
+       fun bar is a, b do print "1"
+
+       fun baz is
+               a
+               bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+       do
+               print "2"
+       end
+end
+
+class B
+       fun foo is a, b
+       fun bar is a, b do print "1"
+
+       fun baz is a, b do
+               bar
+               print "2"
+       end
+
+       fun gaz is
+               a
+               bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+       do
+               bar
+               print "2"
+       end
+end
diff --git a/tests/sav/nitpretty_args3.res b/tests/sav/nitpretty_args3.res
new file mode 100644 (file)
index 0000000..e9c7176
--- /dev/null
@@ -0,0 +1,22 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# A simple module
+module test_mod3
+
+# before
+print "Hello World" # comment
+# after
+
+# end
diff --git a/tests/sav/nitpretty_args4.res b/tests/sav/nitpretty_args4.res
new file mode 100644 (file)
index 0000000..9b7d917
--- /dev/null
@@ -0,0 +1,23 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# comment 1
+interface A end
+
+abstract class B # comment 2
+end
+
+class C end # comment 3
+
+enum D end # comment 4
diff --git a/tests/sav/nitpretty_args5.res b/tests/sav/nitpretty_args5.res
new file mode 100644 (file)
index 0000000..89bf16c
--- /dev/null
@@ -0,0 +1,23 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+module test_class2
+
+# comment
+class A end
+
+class B[T] # comment
+end
+
+private class C[U, V: B[A]] end # comment
diff --git a/tests/sav/nitpretty_args6.res b/tests/sav/nitpretty_args6.res
new file mode 100644 (file)
index 0000000..4e6b922
--- /dev/null
@@ -0,0 +1,33 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# comment
+class A end
+
+class B[T] # comment
+       # comment
+       super A # comment
+       super C[A, B[A]]
+       # comment
+end
+
+class C[U, V: B[A]] end # comment
+
+class D super A end # comment
+
+class E
+       super A # comment
+end
+
+# end
diff --git a/tests/sav/nitpretty_args7.res b/tests/sav/nitpretty_args7.res
new file mode 100644 (file)
index 0000000..e404557
--- /dev/null
@@ -0,0 +1,45 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# comment 1
+class A
+       type FOO: Discrete
+       private var foo: FOO # comment
+
+       # comment 2
+       var bar: Int = 10
+end
+
+class B
+       super A
+
+       redef type FOO: Int
+
+       # comment 3
+       redef fun foo do return bar # comment
+
+       redef fun bar do
+               return 10 # comment 4
+       end
+
+       fun baz do return # comment 5
+       protected fun baz2 do end
+
+       fun other: String do
+               return "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
+                       "aaaaaaaaaaaaaaaaaaaaaaaaaa"
+       end
+end
+
+# end
diff --git a/tests/sav/nitpretty_args8.res b/tests/sav/nitpretty_args8.res
new file mode 100644 (file)
index 0000000..be68683
--- /dev/null
@@ -0,0 +1,29 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+class A
+       fun foo(a, b: Int): Bool do return true # 1
+       fun foo2(a, b: Int): Bool do return true # 2
+       fun foo3(a, b: Int): Bool do return true
+
+       fun foo4(a, b: Int): Bool do
+               var res = true # 3
+               return res # 4
+       end
+
+       fun foo5 do end # 5
+       # fun foo6 do end
+end
+
+# end
diff --git a/tests/sav/nitpretty_args9.res b/tests/sav/nitpretty_args9.res
new file mode 100644 (file)
index 0000000..bd21dbb
--- /dev/null
@@ -0,0 +1,37 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+class A
+       fun foo(aaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb: Int): Bool do
+               return true
+       end # comment
+
+       fun foo2(a, b: Int): Bool do return true # comment
+
+       fun foo3(a, b: Int): Bool do # comment
+               return true # comment
+       end # comment
+
+       fun foo4(a, b: Int): Bool do # comment
+               var res = true # comment
+               return res # comment
+       end # comment
+
+       fun foo5 do end # comment
+
+       fun foo6(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+               aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: Int) do
+               print 1
+       end
+end # comment
diff --git a/tests/test_pretty/test_annot1.nit b/tests/test_pretty/test_annot1.nit
new file mode 100644 (file)
index 0000000..381cc4f
--- /dev/null
@@ -0,0 +1,52 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+module test_annot1 is platform("android")
+
+class A
+       fun foo is a, b
+       fun bar is a, b do print "1"
+       fun baz is a, bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb do print "2"
+end
+
+class B
+       fun foo is
+               a
+               b
+       end
+
+       fun bar is
+               a
+               b
+       do
+               print "1"
+       end
+
+       fun baz is
+               a
+               b
+       do
+               bar
+               print "2"
+       end
+
+       fun gaz is
+               a
+               bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+       do
+               bar
+               print "2"
+       end
+
+end
diff --git a/tests/test_pretty/test_attr1.nit b/tests/test_pretty/test_attr1.nit
new file mode 100644 (file)
index 0000000..e14cef2
--- /dev/null
@@ -0,0 +1,35 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+class A
+       var a: Int # comment
+       private var b: nullable Int # happy
+       protected var c = 10 # ending
+       var d: Int = 10
+
+
+
+
+
+       # Test test...
+       var e: Int writable
+       var f: Int protected writable
+       # Adoc
+var k: Int protected writable = 10
+
+
+
+# more comments
+                       end # end
+
diff --git a/tests/test_pretty/test_attr2.nit b/tests/test_pretty/test_attr2.nit
new file mode 100644 (file)
index 0000000..5b727f7
--- /dev/null
@@ -0,0 +1,24 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+class Foo
+       var _a: Int
+       private var _b: nullable Int
+       protected var _c = 10
+       var _d: Int = 10
+end
+
+var foo = new Foo(1, 2)
+print foo._a
+foo._a = 10
diff --git a/tests/test_pretty/test_call1.nit b/tests/test_pretty/test_call1.nit
new file mode 100644 (file)
index 0000000..805b214
--- /dev/null
@@ -0,0 +1,36 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+class A
+       fun foo do end
+       fun bar(a: Int): Int do return 1
+       fun baz(a, b: Int) do end
+       fun gaz(a: Int, b: Float...) do end
+end
+
+fun top1 do end
+fun top2(a: Int) do end
+
+# comment 1
+var a = new A # comment 2
+a.foo # comment 3
+a.bar(1) # comment 4
+a.baz(1, 2) # comment 5
+top1 # comment 6
+top2(10) # comment 7
+
+print 10 # comment 8
+
+var b = a.bar(1)
+
diff --git a/tests/test_pretty/test_call2.nit b/tests/test_pretty/test_call2.nit
new file mode 100644 (file)
index 0000000..789abdd
--- /dev/null
@@ -0,0 +1,39 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+class A
+       var attr: Int
+       fun foo1=(i: Int) do end
+       fun foo2=(i, j: Int) do end
+       fun [](a: Int): Int is abstract
+       fun []=(a, b: Int) do end
+end
+
+class B
+       fun [](a, b: Int): Int is abstract
+       fun []=(a, b, c: Int) do end
+end
+
+# comment 1
+var a = new A(10) # comment 2
+
+a.foo1 = 10 # comment 3
+a.foo2(1) = 10 # comment 4
+print a[1] # comment 5
+a[1] = 2 # comment 6
+a[2] += 3 # comment 7
+
+var b = new B
+print b[1, 2]
+b[1, 2] = 10
diff --git a/tests/test_pretty/test_class1.nit b/tests/test_pretty/test_class1.nit
new file mode 100644 (file)
index 0000000..fc3f239
--- /dev/null
@@ -0,0 +1,25 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# comment 1
+interface A end
+
+abstract class B # comment 2
+end
+
+class C
+end # comment 3
+
+enum D end # comment 4
+
diff --git a/tests/test_pretty/test_class2.nit b/tests/test_pretty/test_class2.nit
new file mode 100644 (file)
index 0000000..2a61cf1
--- /dev/null
@@ -0,0 +1,25 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+module test_class2
+
+
+# comment
+class A end
+
+class B[T] # comment
+end
+
+private class C[U, V: B[A]] end # comment
+
diff --git a/tests/test_pretty/test_class3.nit b/tests/test_pretty/test_class3.nit
new file mode 100644 (file)
index 0000000..20ea6d3
--- /dev/null
@@ -0,0 +1,44 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# comment
+class A
+end
+
+class B[T] # comment
+# comment
+super A # comment
+
+
+       super C[A, B[A]]
+# comment
+end
+
+class C[U, V: B[A]] end # comment
+
+class D
+       super A
+
+
+end # comment
+
+class E
+
+
+
+                       super A # comment
+end
+
+               # end
+
diff --git a/tests/test_pretty/test_comments1.nit b/tests/test_pretty/test_comments1.nit
new file mode 100644 (file)
index 0000000..d891d45
--- /dev/null
@@ -0,0 +1,101 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+# toplevel comment
+
+
+
+
+
+
+# block
+# block
+# block
+
+
+
+
+
+# Adoc1
+class A                                                # ending comments
+
+       super Object
+       # super Int
+
+       
+       super String
+       # super Truc
+
+
+
+# inclass comments
+       # comm
+       #    ented
+       #      blocks
+
+
+
+       # Adoc2
+       fun foo do
+               
+               # comment
+
+
+
+               var truc
+
+               # comment
+               # comment
+
+               
+               
+               # comment
+               
+               
+               var chose
+
+               # comment
+       end
+
+# comm
+#    ented
+#      blocks
+
+
+       fun bar do end
+       
+       
+fun baz do end
+# comment before end
+
+end # ending comments
+
+# comm
+#    ented
+#      blocks
+
+abstract class B # comment
+end
+
+abstract class C
+end
+
+abstract class B # comment 2
+
+end
+
+abstract class C
+
+end
diff --git a/tests/test_pretty/test_extern1.nit b/tests/test_pretty/test_extern1.nit
new file mode 100644 (file)
index 0000000..d2fc373
--- /dev/null
@@ -0,0 +1,86 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import end
+intrude import standard::kernel
+private import standard::string
+
+`{`}
+
+`{
+#ifdef truc
+       #undef truc
+#endif
+`}
+
+in "C headers" `{
+       #include <errno.h>
+`}
+
+fun err: Int is extern `{ return 1; `}
+
+fun errno: Int is extern `{
+       return errno;
+`}
+
+fun errnoooooooooooooooooooooooooooooooooooooooooooooooooooooooooo: Int is extern `{ return errno; `}
+
+private class A
+    var my_attr = 1234
+
+    fun baz( msg : String ) import String.length, String.to_cstring, my_attr, my_attr= `{
+               char *c_msg;
+               int msg_len;
+
+               /* String_to_cstring isa a allback to msg.to_cstring */ 
+               c_msg = String_to_cstring( msg );
+
+               /* String_length is a callback to msg.length */
+               msg_len = String_length( msg );
+
+               printf( "received msg: %s, of length = %d\n", c_msg, msg_len );
+
+               /* A_my_attr is a callback to the getter of self.my_attr */
+               printf( "old attr %d\n", A_my_attr(recv) );
+
+               if(chose)
+                       truc;
+               else
+                       chose;
+
+               /* A_my_attr is a callback to the setter of self.my_attr= */
+               A_my_attr__assign( recv, msg_len );
+    `}
+end
+
+extern class TimeT `{time_t`}
+       new `{ return time(NULL); `}
+       new from_i(i: Int) `{ return i; `}
+
+       fun update `{ time(&recv); `}
+
+       fun ctime: String import NativeString.to_s_with_copy `{
+               return NativeString_to_s_with_copy( ctime(&recv) );
+       `}
+
+       # Difference in secondes from start (self if the end time)
+       fun difftime(start: TimeT): Float `{ return difftime(recv, start); `}
+
+       private fun intern_poll(in_fds: Array[Int], out_fds: Array[Int]) : nullable Int is extern import Array[Int].length, Array[Int].[], Int.as(nullable Int) `{`}
+end
+
+fun address_is_null: Bool is extern "address_is_null"
+
+fun free `{ free(recv); `}
+
diff --git a/tests/test_pretty/test_if1.nit b/tests/test_pretty/test_if1.nit
new file mode 100644 (file)
index 0000000..60bf5ef
--- /dev/null
@@ -0,0 +1,50 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+var a = 1
+var b = 2
+
+if a == b then a = b
+
+if a != b then
+       a = b
+       a = b
+end
+
+if a > b then
+       b = a
+       a = b
+else
+       a = b
+       a = b
+end
+
+if a < b then
+       a = b
+       a = b
+else if a == b then
+       b = a
+       a = b
+end
+
+if a < b then
+       a = b
+       a = b
+else if a == b then
+       b = b
+       a = b
+else
+       a = b
+       a = b
+end
diff --git a/tests/test_pretty/test_if2.nit b/tests/test_pretty/test_if2.nit
new file mode 100644 (file)
index 0000000..45c3d72
--- /dev/null
@@ -0,0 +1,81 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# comment
+var a = 1# comment
+# comment
+var b = 2# comment
+
+# comment
+if a == b then a = b# comment
+
+# comment
+if a != b then# comment
+# comment
+       a = b# comment
+# comment
+       a = b# comment
+# comment
+end# comment
+
+# comment
+if a > b then# comment
+# comment
+       b = a# comment
+# comment
+       a = b# comment
+# comment
+else# comment
+# comment
+       a = b# comment
+# comment
+       a = b# comment
+# comment
+end# comment
+
+# comment
+if a < b then# comment
+# comment
+       a = b# comment
+# comment
+       a = b# comment
+# comment
+else if a == b then# comment
+# comment
+       b = a# comment
+# comment
+       a = b# comment
+# comment
+end# comment
+
+# comment
+if a < b then# comment
+# comment
+       a = b# comment
+# comment
+       a = b# comment
+# comment
+else if a == b then# comment
+# comment
+       b = b# comment
+# comment
+       a = b# comment
+# comment
+else# comment
+# comment
+       a = b# comment
+# comment
+       a = b# comment
+# comment
+end# comment
diff --git a/tests/test_pretty/test_if3.nit b/tests/test_pretty/test_if3.nit
new file mode 100644 (file)
index 0000000..8aa3fb2
--- /dev/null
@@ -0,0 +1,67 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+var a = 1
+var b = 2
+
+# 0
+if a == b then # 1
+       # 2
+else # 3
+       # 4
+end # 5
+
+if a == b then print a # printing a
+
+if a == b then
+       print a # printing a
+end
+
+if a == b then
+       print a
+end # end
+
+if a == b then a = b
+
+if a == b then
+
+else
+
+end
+
+if a==b then end
+
+if a != b then
+       a = b
+end
+
+if a > b then
+       a = b
+else
+       a = b
+end
+
+if a < b then
+       a = b
+else if a == b then
+       a = b
+end
+
+if a < b then
+       a = b
+else if a == b then
+       a = b
+else
+       a = b
+end
diff --git a/tests/test_pretty/test_indent1.nit b/tests/test_pretty/test_indent1.nit
new file mode 100644 (file)
index 0000000..3812d9d
--- /dev/null
@@ -0,0 +1,106 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+class Foo
+       fun bar: Bool do return true
+
+       fun foo(other: Foo): Foo
+       do
+               if other.bar then return other else
+                       return self
+               end
+       end
+
+       fun baz: Int do
+               var nb = 0
+               while nb < 10 do
+                       print nb
+                       nb += 1
+end # 1
+               return nb
+       end
+
+       fun gaz: Int
+       do
+           if bar # 2
+           then # 3
+               return 1
+           else
+               return -1 # 4
+           end
+       end
+end
+
+class Test[E]
+       var heap: ArrayHeap[E]
+
+       init to(comparator: Comparator[E]) do
+               heap = new ArrayHeap[E](comparator)
+       end
+
+       init from(comparator: Comparator[E], items: Collection[E]) do
+               heap = new ArrayHeap[E].from(comparator, items.to_a)
+       end
+
+       fun count(k: E): Int do if heap.has(k) then return 1 else return 0
+
+       fun node_at_idx(i: Int, k: E) do
+               while heap != null do
+                       if heap.is_empty or i == k then # FIXME prefilter because the compiler is not smart enought yet
+                               break
+                       end
+               end
+       end
+
+       fun save_those_nodes(nodes: Collection[Object]) do
+               for node in nodes do count(node)
+       end
+end
+
+fun foo do
+       if last_slash > 0 then
+               return substring( last_slash+1, length )
+       else
+               return null
+       end
+end
+
+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."
+
+var lorem = "lorem" 
+var ipsum = "ipsum" # for fun
+
+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
+
+var title = "title"
+var links = new Array[String] # why not?
+
+var body = """
+<!DOCTYPE html>
+<head>
+       <meta charset="utf-8">
+       <meta http-equiv="X-UA-Compatible" content="IE=edge">
+       <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
+       <title>{{{title}}}</title>
+</head>
+<body>
+       <div class="container">
+               <h1>{{{title}}}</h1>
+               <ul>
+                       <li>{{{links.join("</li>\n\t\t\t<li>")}}}</li>
+               </ul>
+       </div>
+</body>
+</html>"""
+
diff --git a/tests/test_pretty/test_loop1.nit b/tests/test_pretty/test_loop1.nit
new file mode 100644 (file)
index 0000000..1ccf518
--- /dev/null
@@ -0,0 +1,36 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+var a = 1
+var b = 2
+
+while a != b do # comment 1
+       # comment 2
+       var tmp = a
+       a = b
+       b = tmp
+       # comment 3
+end
+
+# comment 4
+while a != b do
+       a = b
+end # comment 5
+
+while a != b do
+       # comment 6
+end # comment 7
+
+# end
+
diff --git a/tests/test_pretty/test_loop2.nit b/tests/test_pretty/test_loop2.nit
new file mode 100644 (file)
index 0000000..546fc90
--- /dev/null
@@ -0,0 +1,53 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+var a = 0
+var b = 2
+
+do # comment 1
+       # comment 2
+       var tmp = a
+       a = b
+       b = tmp
+       # comment 3
+end
+
+# comment 4
+do
+       a = b
+end # comment 5
+
+do
+       # comment 6
+end
+
+if a > b then loop print a # test
+
+if a > b then
+       loop print a
+end
+
+if a > b then
+       loop
+               print a
+       end
+end
+
+if a > b then
+       loop
+               # comment 7
+               print a
+       end
+end
+
diff --git a/tests/test_pretty/test_loop3.nit b/tests/test_pretty/test_loop3.nit
new file mode 100644 (file)
index 0000000..94e85fb
--- /dev/null
@@ -0,0 +1,29 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+var a = 0
+
+for i in [1, 2, 3] do# comment 1
+       # comment 2
+       a += i
+end
+
+# comment 4
+for i in [1..3] do
+       a += i
+end # comment 5
+
+for i in [1..3[ do
+       # comment 6
+end
diff --git a/tests/test_pretty/test_mod1.nit b/tests/test_pretty/test_mod1.nit
new file mode 100644 (file)
index 0000000..f55be8f
--- /dev/null
@@ -0,0 +1,18 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+
+# An empty module
+
diff --git a/tests/test_pretty/test_mod2.nit b/tests/test_pretty/test_mod2.nit
new file mode 100644 (file)
index 0000000..c8adb76
--- /dev/null
@@ -0,0 +1,24 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Testing only imports
+
+# Module comment
+module test_mod2 # second comment
+
+   import standard::kernel
+#import standard::string
+
+       import template # no need for string
+# import standard
diff --git a/tests/test_pretty/test_mod3.nit b/tests/test_pretty/test_mod3.nit
new file mode 100644 (file)
index 0000000..2fa4856
--- /dev/null
@@ -0,0 +1,25 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# A simple module
+module test_mod3
+
+                               # before
+               print      "Hello World"      # comment
+               # after
+
+               # end
+
+
+
diff --git a/tests/test_pretty/test_op1.nit b/tests/test_pretty/test_op1.nit
new file mode 100644 (file)
index 0000000..4fec81e
--- /dev/null
@@ -0,0 +1,21 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+var a: nullable Int = 1
+var b: nullable Int = a.as(Int)
+var c: nullable Int = a.as(not null)
+
+assert c isa Int
+assert test1: c isa Int
+assert test2: c isa Int else abort
diff --git a/tests/test_pretty/test_op2.nit b/tests/test_pretty/test_op2.nit
new file mode 100644 (file)
index 0000000..3562617
--- /dev/null
@@ -0,0 +1,31 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+var a = 1
+var b = 2
+
+assert a == 2
+assert not a < 2 # comment 1
+assert a > 2 and b >= 2
+assert b != 2 or a <= 2
+assert b != null # comment 2
+
+# comment 3
+print a + b
+print a - b # comment 4
+print a * b
+print a / b
+print a % b
+
+print -a # comment 5
diff --git a/tests/test_pretty/test_op3.nit b/tests/test_pretty/test_op3.nit
new file mode 100644 (file)
index 0000000..641f01c
--- /dev/null
@@ -0,0 +1,27 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+var a = 1
+var b = 2
+
+assert not a < 2 and (a == b or a > b)# comment 1
+assert not a < 2 and (a == b or ((a > b) or a <= b))
+assert (a > 2 and b >= 2)
+assert (b >= 2)
+
+# comment 3
+var c = a + (b - a)
+var d = (a - b) + c # comment 4
+var e = (-a) # comment 5
+var f = -(a - c)
diff --git a/tests/test_pretty/test_prims1.nit b/tests/test_pretty/test_prims1.nit
new file mode 100644 (file)
index 0000000..721a3e1
--- /dev/null
@@ -0,0 +1,48 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# prims
+
+var a = true
+var b = false
+
+var c          =        10
+       var d = -10
+var e = 1.12
+
+var f = -1.12
+var n = 'a'
+var o = null
+var p = 0x12345678
+
+# strings
+
+var g = "test"
+var h1 = "Hello {g}"
+var h2 = "Hello \"{g}\" Hello"
+var h3 = "Hello {g}"
+       var m = """
+bla
+       bla
+
+bla"""
+
+       # arrays
+
+var j = [1,2,3]
+var k=[ 1 .. 2 [
+var l  = [1..2]
+
+
+
diff --git a/tests/test_pretty/test_prop1.nit b/tests/test_pretty/test_prop1.nit
new file mode 100644 (file)
index 0000000..0b46c27
--- /dev/null
@@ -0,0 +1,41 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# comment 1
+class A
+type FOO: Discrete
+       private var foo: FOO # comment
+# comment 2
+       var bar: Int = 10
+end
+
+class B
+       super A
+
+       redef type FOO: Int
+# comment 3
+       redef fun foo do return bar # comment
+       redef fun bar
+       do
+               return 10 # comment 4
+       end
+       fun baz do
+               return
+       end # comment 5
+       protected fun baz2 do end
+       fun other: String do return "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+end
+
+# end
+
diff --git a/tests/test_pretty/test_prop2.nit b/tests/test_pretty/test_prop2.nit
new file mode 100644 (file)
index 0000000..caae0a8
--- /dev/null
@@ -0,0 +1,34 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+class A
+       fun foo(a, b: Int): Bool do return true # 1
+
+       fun foo2(a, b: Int): Bool do return true end # 2
+
+       fun foo3(a, b: Int): Bool do
+               return true
+       end
+
+       fun foo4(a, b: Int): Bool do
+               var res = true # 3
+               return res # 4
+       end
+
+       fun foo5 do end # 5
+       # fun foo6 do end
+end
+
+# end
+
diff --git a/tests/test_pretty/test_prop3.nit b/tests/test_pretty/test_prop3.nit
new file mode 100644 (file)
index 0000000..60408c5
--- /dev/null
@@ -0,0 +1,35 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+class A
+       fun foo(aaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb: Int): Bool do return true # comment
+
+       fun foo2(a, b: Int): Bool do return true end # comment
+
+       fun foo3(a, b: Int): Bool do # comment
+               return true # comment
+       end # comment
+
+       fun foo4(a, b: Int): Bool do # comment
+               var res = true # comment
+               return res # comment
+       end # comment
+
+       fun foo5 do end # comment
+
+       fun foo6(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: Int) do
+               print 1
+       end
+
+end # comment