From 7dafe1a3731fa933c0613fe22d6ec802179c7aac Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Mon, 15 Jul 2019 23:15:39 +0200 Subject: [PATCH] :white_check_mark: Add tests --- tests/benchmark/string-equals.gw | 21 ++++++++++++++++++ tests/benchmark/string-equals.py | 35 ++++++++++++++++++++++++++++++ tests/benchmark/string-equals.wren | 24 ++++++++++++++++++++ tests/new/from_owner1.gw | 6 +++++ tests/new/from_owner2.gw | 6 +++++ tests/new/from_owner3.gw | 1 + 6 files changed, 93 insertions(+) create mode 100644 tests/benchmark/string-equals.gw create mode 100644 tests/benchmark/string-equals.py create mode 100644 tests/benchmark/string-equals.wren create mode 100644 tests/new/from_owner1.gw create mode 100644 tests/new/from_owner2.gw create mode 100644 tests/new/from_owner3.gw diff --git a/tests/benchmark/string-equals.gw b/tests/benchmark/string-equals.gw new file mode 100644 index 00000000..6dfa7e62 --- /dev/null +++ b/tests/benchmark/string-equals.gw @@ -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 index 00000000..8829b5c2 --- /dev/null +++ b/tests/benchmark/string-equals.py @@ -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 index 00000000..0c87bcc2 --- /dev/null +++ b/tests/benchmark/string-equals.wren @@ -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/from_owner1.gw b/tests/new/from_owner1.gw new file mode 100644 index 00000000..fc45b6c7 --- /dev/null +++ b/tests/new/from_owner1.gw @@ -0,0 +1,6 @@ +class C { + int i; + class D { + i; + } +} diff --git a/tests/new/from_owner2.gw b/tests/new/from_owner2.gw new file mode 100644 index 00000000..e1dc893d --- /dev/null +++ b/tests/new/from_owner2.gw @@ -0,0 +1,6 @@ +class C { + int i; + class D { + this.i; + } +} diff --git a/tests/new/from_owner3.gw b/tests/new/from_owner3.gw new file mode 100644 index 00000000..445afa5f --- /dev/null +++ b/tests/new/from_owner3.gw @@ -0,0 +1 @@ +Shred.me; -- 2.43.0