Commit d5a585122e8c92b4d08acffe0b8ae2045d7095df

Golmote 2015-08-29T12:48:05

Merge pull request #706 from Golmote/tests-ruby Add tests for Ruby

diff --git a/tests/languages/ruby/builtin_feature.test b/tests/languages/ruby/builtin_feature.test
new file mode 100644
index 0000000..e1bb32e
--- /dev/null
+++ b/tests/languages/ruby/builtin_feature.test
@@ -0,0 +1,29 @@
+Array Bignum Binding
+Class;
+Continuation Dir Exception
+FalseClass File Stat File
+Fixnum Fload Hash Integer
+IO MatchData Method Module
+NilClass Numeric Object
+Proc Range Regexp String
+Struct TMS Symbol ThreadGroup
+Thread Time TrueClass
+
+----------------------------------------------------
+
+[
+	["builtin", "Array"], ["builtin", "Bignum"], ["builtin", "Binding"],
+	["builtin", "Class"], ["punctuation", ";"],
+	["builtin", "Continuation"], ["builtin", "Dir"], ["builtin", "Exception"],
+	["builtin", "FalseClass"], ["builtin", "File"], ["builtin", "Stat"], ["builtin", "File"],
+	["builtin", "Fixnum"], ["builtin", "Fload"], ["builtin", "Hash"], ["builtin", "Integer"],
+	["builtin", "IO"], ["builtin", "MatchData"], ["builtin", "Method"], ["builtin", "Module"],
+	["builtin", "NilClass"], ["builtin", "Numeric"], ["builtin", "Object"],
+	["builtin", "Proc"], ["builtin", "Range"], ["builtin", "Regexp"], ["builtin", "String"],
+	["builtin", "Struct"], ["builtin", "TMS"], ["builtin", "Symbol"], ["builtin", "ThreadGroup"],
+	["builtin", "Thread"], ["builtin", "Time"], ["builtin", "TrueClass"]
+]
+
+----------------------------------------------------
+
+Checks for all builtins.
\ No newline at end of file
diff --git a/tests/languages/ruby/comment_feature.test b/tests/languages/ruby/comment_feature.test
new file mode 100644
index 0000000..054d602
--- /dev/null
+++ b/tests/languages/ruby/comment_feature.test
@@ -0,0 +1,13 @@
+#
+# foobar
+
+----------------------------------------------------
+
+[
+	["comment", "#"],
+	["comment", "# foobar"]
+]
+
+----------------------------------------------------
+
+Checks for comments.
\ No newline at end of file
diff --git a/tests/languages/ruby/constant_feature.test b/tests/languages/ruby/constant_feature.test
new file mode 100644
index 0000000..220cf74
--- /dev/null
+++ b/tests/languages/ruby/constant_feature.test
@@ -0,0 +1,21 @@
+Foobar
+FOO_BAR_42
+F
+FOO
+BAR?
+BAZ!
+
+----------------------------------------------------
+
+[
+	["constant", "Foobar"],
+	["constant", "FOO_BAR_42"],
+	["constant", "F"],
+	["constant", "FOO"],
+	["constant", "BAR?"],
+	["constant", "BAZ!"]
+]
+
+----------------------------------------------------
+
+Checks for constants.
\ No newline at end of file
diff --git a/tests/languages/ruby/keyword_feature.test b/tests/languages/ruby/keyword_feature.test
new file mode 100644
index 0000000..2292cd0
--- /dev/null
+++ b/tests/languages/ruby/keyword_feature.test
@@ -0,0 +1,39 @@
+alias and BEGIN begin
+break case
+class;
+def
+define_method defined
+do each else elsif
+END end ensure false
+for if in module
+new;
+next nil not
+or raise redo require
+rescue retry return
+self super then throw
+true undef unless until
+when while yield
+
+----------------------------------------------------
+
+[
+	["keyword", "alias"], ["keyword", "and"], ["keyword", "BEGIN"], ["keyword", "begin"],
+	["keyword", "break"], ["keyword", "case"],
+	["keyword", "class"], ["punctuation", ";"],
+	["keyword", "def"],
+	["keyword", "define_method"], ["keyword", "defined"],
+	["keyword", "do"], ["keyword", "each"], ["keyword", "else"], ["keyword", "elsif"],
+	["keyword", "END"], ["keyword", "end"], ["keyword", "ensure"], ["keyword", "false"],
+	["keyword", "for"], ["keyword", "if"], ["keyword", "in"], ["keyword", "module"],
+	["keyword", "new"], ["punctuation", ";"],
+	["keyword", "next"], ["keyword", "nil"], ["keyword", "not"],
+	["keyword", "or"], ["keyword", "raise"], ["keyword", "redo"], ["keyword", "require"],
+	["keyword", "rescue"], ["keyword", "retry"], ["keyword", "return"],
+	["keyword", "self"], ["keyword", "super"], ["keyword", "then"], ["keyword", "throw"],
+	["keyword", "true"], ["keyword", "undef"], ["keyword", "unless"], ["keyword", "until"],
+	["keyword", "when"], ["keyword", "while"], ["keyword", "yield"]
+]
+
+----------------------------------------------------
+
+Checks for all keywords.
\ No newline at end of file
diff --git a/tests/languages/ruby/regex_feature.test b/tests/languages/ruby/regex_feature.test
new file mode 100644
index 0000000..da20fe2
--- /dev/null
+++ b/tests/languages/ruby/regex_feature.test
@@ -0,0 +1,15 @@
+/[foo]\/bar/gim
+/[bar]/,
+/./i;
+
+----------------------------------------------------
+
+[
+	["regex", "/[foo]\\/bar/gim"],
+	["regex", "/[bar]/"], ["punctuation", ","],
+	["regex", "/./i"], ["punctuation", ";"]
+]
+
+----------------------------------------------------
+
+Checks for regex.
\ No newline at end of file
diff --git a/tests/languages/ruby/string_feature.test b/tests/languages/ruby/string_feature.test
new file mode 100644
index 0000000..889ab14
--- /dev/null
+++ b/tests/languages/ruby/string_feature.test
@@ -0,0 +1,44 @@
+''
+""
+'foo'
+"foo"
+'foo\
+bar'
+"foo\
+bar"
+
+'foo #{42} bar'
+"foo #{ 42 } bar"
+
+----------------------------------------------------
+
+[
+	["string", ["''"]],
+	["string", ["\"\""]],
+	["string", ["'foo'"]],
+	["string", ["\"foo\""]],
+	["string", ["'foo\\\r\nbar'"]],
+	["string", ["\"foo\\\r\nbar\""]],
+	["string", [
+		"'foo ",
+		["interpolation", [
+			["delimiter", "#{"],
+			["number", "42"],
+			["delimiter", "}"]
+		]],
+		" bar'"
+	]],
+	["string", [
+        "\"foo ",
+        ["interpolation", [
+            ["delimiter", "#{"],
+            ["number", "42"],
+            ["delimiter", "}"]
+        ]],
+        " bar\""
+    ]]
+]
+
+----------------------------------------------------
+
+Checks for strings and string interpolation.
\ No newline at end of file
diff --git a/tests/languages/ruby/symbol_feature.test b/tests/languages/ruby/symbol_feature.test
new file mode 100644
index 0000000..6a51758
--- /dev/null
+++ b/tests/languages/ruby/symbol_feature.test
@@ -0,0 +1,17 @@
+:_
+:foo
+:BAR?
+:Baz_42!
+
+----------------------------------------------------
+
+[
+	["symbol", ":_"],
+	["symbol", ":foo"],
+	["symbol", ":BAR?"],
+	["symbol", ":Baz_42!"]
+]
+
+----------------------------------------------------
+
+Checks for symbols.
\ No newline at end of file
diff --git a/tests/languages/ruby/variable_feature.test b/tests/languages/ruby/variable_feature.test
new file mode 100644
index 0000000..3b7b7c7
--- /dev/null
+++ b/tests/languages/ruby/variable_feature.test
@@ -0,0 +1,27 @@
+$_
+$foo
+$BAR?
+$Baz_42!
+
+@_
+@foo
+@BAR?
+@Baz_42!
+
+----------------------------------------------------
+
+[
+	["variable", "$_"],
+	["variable", "$foo"],
+	["variable", "$BAR?"],
+	["variable", "$Baz_42!"],
+
+	["variable", "@_"],
+	["variable", "@foo"],
+	["variable", "@BAR?"],
+	["variable", "@Baz_42!"]
+]
+
+----------------------------------------------------
+
+Checks for variables.
\ No newline at end of file