]> Nishi Git Mirror - gwion.git/commitdiff
:white_check_mark: Add more tests
authorfennecdjay <astor.jeremie@wanadoo.fr>
Sun, 14 Jul 2019 23:42:30 +0000 (01:42 +0200)
committerfennecdjay <astor.jeremie@wanadoo.fr>
Sun, 14 Jul 2019 23:42:30 +0000 (01:42 +0200)
tests/benchmark/for.dart [new file with mode: 0644]
tests/benchmark/for.gw [new file with mode: 0644]
tests/benchmark/for.lua [new file with mode: 0644]
tests/benchmark/for.py [new file with mode: 0644]
tests/benchmark/for.rb [new file with mode: 0644]
tests/benchmark/for.wren [new file with mode: 0644]
tests/benchmark/string_equals.gw [new file with mode: 0644]
tests/benchmark/string_equals.py [new file with mode: 0644]
tests/benchmark/string_equals.wren [new file with mode: 0644]
tests/new/ternary_opt.gw [new file with mode: 0644]
tests/pp/__func__.gw [new file with mode: 0644]

diff --git a/tests/benchmark/for.dart b/tests/benchmark/for.dart
new file mode 100644 (file)
index 0000000..14aadbd
--- /dev/null
@@ -0,0 +1,10 @@
+main() {
+  var list = [];
+
+  for (var i = 0; i < 1000000; i++) list.add(i);
+
+  var sum = 0;
+  for (i in list) sum += i;
+
+  print(sum);
+}
diff --git a/tests/benchmark/for.gw b/tests/benchmark/for.gw
new file mode 100644 (file)
index 0000000..6ec6aaa
--- /dev/null
@@ -0,0 +1,10 @@
+int list[0];
+
+for (int i; i < 1000000; ++i)
+ list << i;
+
+int sum;
+for(auto i : list)
+  i +=> sum;
+
+<<< sum >>>;
diff --git a/tests/benchmark/for.lua b/tests/benchmark/for.lua
new file mode 100644 (file)
index 0000000..b03654b
--- /dev/null
@@ -0,0 +1,10 @@
+local list = {}
+for i = 0, 999999 do
+  list[i] = i
+end
+
+local sum = 0
+for k, i in pairs(list) do
+  sum = sum + i
+end
+io.write(sum .. "\n")
diff --git a/tests/benchmark/for.py b/tests/benchmark/for.py
new file mode 100644 (file)
index 0000000..cf31dda
--- /dev/null
@@ -0,0 +1,16 @@
+from __future__ import print_function
+
+# Map "range" to an efficient range in both Python 2 and 3.
+try:
+    range = xrange
+except NameError:
+    pass
+
+list = []
+for i in range(0, 1000000):
+  list.append(i)
+
+sum = 0
+for i in list:
+  sum += i
+print(sum)
diff --git a/tests/benchmark/for.rb b/tests/benchmark/for.rb
new file mode 100644 (file)
index 0000000..87b9d79
--- /dev/null
@@ -0,0 +1,6 @@
+list = []
+1000000.times {|i| list << i}
+
+sum = 0
+list.each {|i| sum += i}
+puts sum
diff --git a/tests/benchmark/for.wren b/tests/benchmark/for.wren
new file mode 100644 (file)
index 0000000..ef25978
--- /dev/null
@@ -0,0 +1,8 @@
+var list = []
+
+for (i in 0...1000000) list.add(i)
+
+var sum = 0
+for (i in list) sum = sum + i
+
+System.print(sum)
diff --git a/tests/benchmark/string_equals.gw b/tests/benchmark/string_equals.gw
new file mode 100644 (file)
index 0000000..6dfa7e6
--- /dev/null
@@ -0,0 +1,21 @@
+int count;
+for (int i; i < 1000000; ++i) {
+  if ("abc" == "abc") ++count;
+  if ("a slightly longer string" ==
+      "a slightly longer string") ++count;
+  if ("a significantly longer string but still not overwhelmingly long string" ==
+      "a significantly longer string but still not overwhelmingly long string") ++count;
+
+  if ("" == "abc") ++count;
+  if ("abc" == "abcd") ++count;
+  if ("changed one character" == "changed !ne character") ++count;
+#!  if ("123" == 123) ++count
+  if ("a slightly longer string" ==
+      "a slightly longer string!") ++count;
+  if ("a slightly longer string" ==
+      "a slightly longer strinh") ++count;
+  if ("a significantly longer string but still not overwhelmingly long string" ==
+      "another") ++count;
+}
+
+<<< count >>>;
diff --git a/tests/benchmark/string_equals.py b/tests/benchmark/string_equals.py
new file mode 100644 (file)
index 0000000..8829b5c
--- /dev/null
@@ -0,0 +1,35 @@
+from __future__ import print_function
+
+import time
+start = time.clock()
+
+count = 0
+for i in range(0, 1000000):
+  if "abc" == "abc":
+    count = count + 1
+  if "a slightly longer string" == \
+     "a slightly longer string":
+      count = count + 1
+  if "a significantly longer string but still not overwhelmingly long string" == \
+     "a significantly longer string but still not overwhelmingly long string":
+      count = count + 1
+
+  if "" == "abc":
+    count = count + 1
+  if "abc" == "abcd":
+    count = count + 1
+  if "changed one character" == "changed !ne character":
+    count = count + 1
+  if "123" == 123: count = count + 1
+  if "a slightly longer string" == \
+     "a slightly longer string!":
+      count = count + 1
+  if "a slightly longer string" == \
+     "a slightly longer strinh":
+      count = count + 1
+  if "a significantly longer string but still not overwhelmingly long string" == \
+     "another":
+      count = count + 1
+
+print(count)
+print("elapsed: " + str(time.clock() - start))
diff --git a/tests/benchmark/string_equals.wren b/tests/benchmark/string_equals.wren
new file mode 100644 (file)
index 0000000..0c87bcc
--- /dev/null
@@ -0,0 +1,24 @@
+var start = System.clock
+
+var count = 0
+for (i in 1..1000000) {
+  if ("abc" == "abc") count = count + 1
+  if ("a slightly longer string" ==
+      "a slightly longer string") count = count + 1
+  if ("a significantly longer string but still not overwhelmingly long string" ==
+      "a significantly longer string but still not overwhelmingly long string") count = count + 1
+
+  if ("" == "abc") count = count + 1
+  if ("abc" == "abcd") count = count + 1
+  if ("changed one character" == "changed !ne character") count = count + 1
+  if ("123" == 123) count = count + 1
+  if ("a slightly longer string" ==
+      "a slightly longer string!") count = count + 1
+  if ("a slightly longer string" ==
+      "a slightly longer strinh") count = count + 1
+  if ("a significantly longer string but still not overwhelmingly long string" ==
+      "another") count = count + 1
+}
+
+System.print(count)
+System.print("elapsed: %(System.clock - start)")
diff --git a/tests/new/ternary_opt.gw b/tests/new/ternary_opt.gw
new file mode 100644 (file)
index 0000000..a742d92
--- /dev/null
@@ -0,0 +1,2 @@
+repeat(10)
+  <<< maybe ? : -1 >>>;
diff --git a/tests/pp/__func__.gw b/tests/pp/__func__.gw
new file mode 100644 (file)
index 0000000..6ae55e1
--- /dev/null
@@ -0,0 +1,13 @@
+<<< __func__ >>>;
+fun void test() {
+<<< __func__ >>>;
+}
+test();
+class C {
+  <<< __func__ >>>;
+  fun void test() {
+    <<< __func__ >>>;
+  }
+  test();
+}
+C c;