1
1
mirror of https://github.com/github/semantic.git synced 2024-12-29 18:06:14 +03:00
semantic/test/corpus/generated/ruby.json

200 lines
5.7 KiB
JSON
Raw Normal View History

2016-10-19 20:33:21 +03:00
[
{
"language": "ruby",
"fileExt": ".rb",
"repoUrl": "https://github.com/diff-fixtures/ruby.git",
2016-10-19 20:33:21 +03:00
"syntaxes": [
{
"syntax": "assignment",
"insert": "x = 0",
"replacement": "x = 1",
},
{
"syntax": "comment",
"insert": "# This is a comment",
"replacement": "=begin\nThis is a multiline\ncomment\n=end",
},
2016-10-21 23:55:00 +03:00
{
"syntax": "number",
"insert": "1234\n1_234\n0d1_234\n0xa_bcd_ef0_123_456_789\n0o1234567\n0b1_0\n1.234_5e678_90\n",
"replacement": "1235\n1_235\n0d1_235\n0xa_bcd_ef0_123_456_788\n0o1234576\n0b1_1\n1.234_5e678_91\n",
},
{
"syntax": "symbol",
"insert": ":foo\n:'foo'\n:\"foo\"",
"replacement": ":bar\n:'bar'\n:\"bar\"",
},
{
"syntax": "string",
"insert": "''\n'foo with \"bar\"'",
"replacement": "\"\"\n\"bar with 'foo'\"",
},
{
2016-10-21 23:55:00 +03:00
"syntax": "interpolation",
"insert": ":\"foo #{bar}\"\n\"foo #{bar}\"",
"replacement": ":\"bar #{foo}\"\n\"bar #{foo}\"",
2016-10-22 00:41:04 +03:00
},
{
"syntax": "delimiter",
"insert": "%q#a#\n%q<a<b>c>\n%#a#\n%Q#a#\n%<a<b>c>\n%Q<a<b>c>",
"replacement": "%q/b/\n%q{d{e}f}\n%/b/\n%Q/b/\n%{d{e}f}\n%Q{d{e}f}",
2016-10-22 01:52:40 +03:00
},
{
2016-10-31 23:21:58 +03:00
"syntax": "math-assignment",
2016-10-22 01:52:40 +03:00
"insert": "x += 1\nx -= 1\nx *= 1\nx /= 1\nx **= 1",
"replacement": "x+= 2\nx -= 1\nx *= 1\nx /= 1\nx **= 1",
2016-10-24 20:43:31 +03:00
},
{
2016-10-31 23:21:58 +03:00
"syntax": "conditional-assignment",
2016-10-24 20:43:31 +03:00
"insert": "x ||= 5",
"replacement": "x &&= 7",
},
{
2016-10-31 23:14:58 +03:00
"syntax": "multiple-assignments",
2016-10-24 20:43:31 +03:00
"insert": "x, y, z = 10, 20, 30",
"replacement": "x, y = aVariable, 40",
},
{
2016-10-31 23:21:58 +03:00
"syntax": "pseudo-variables",
2016-10-24 20:43:31 +03:00
"insert": "nil\nself\nfalse\ntrue",
"replacement": "self\nNIL\nTRUE\nFALSE",
},
{
"syntax": "subshell",
"insert": "`ls -la`",
"replacement": "`git status`",
},
{
"syntax": "hash",
"insert": "{ :key1 => \"value\", :key2 => 1, \"key3\" => false, :\"symbol_key\" => 10 }",
"replacement": "{ key1: \"changed value\", key2: 2, key3: true }",
},
{
"syntax": "boolean-operator",
"insert": "a || b",
"replacement": "a && b",
},
{
"syntax": "relational-operator",
"insert": "x == y\nx != y\nx === y",
"replacement": "x <=> y\nx =~ y\nx =! y",
},
{
"syntax": "comparision-operator",
"insert": "x < y\na > b",
"replacement": "x <= y\na >= b",
},
{
"syntax": "bitwise-operator",
"insert": "a | b\na >> b\na ^ b",
"replacement": "a & b\na << b",
},
{
"syntax": "ternary",
"insert": "condition ? case1 : case2",
"replacement": "if condition then case 1 else case2",
2016-10-24 22:23:10 +03:00
},
{
"syntax": "method-invocation",
"insert": "print\nfoo.bar\nbar",
"replacement": "print(\"hello world\")\nfoo.bar()\nbar 2, 3\nbar(2, 3)",
},
{
"syntax": "case-statement",
"insert": "case foo\nwhen bar\nend",
"replacement": "case foo\nwhen bar\nelse\nend",
},
{
"syntax": "class",
"insert": "class Foo < Super\n def test; end\nend",
2016-10-26 20:27:38 +03:00
"replacement": "class Foo\n def test; end\nend",
},
2016-10-27 22:47:27 +03:00
{
"syntax": "module",
"insert": "module Foo\n class Bar\n def self.test; end\nend\nend",
"replacement": "class Bar::Foo\nend",
},
2016-10-26 20:27:38 +03:00
{
"syntax": "return",
"insert": "return foo",
"replacement": "return",
},
{
"syntax": "yield",
"insert": "yield foo",
"replacement": "yield",
},
{
"syntax": "while",
"insert": "while foo do\nend\nfoo while run",
"replacement": "while foo\n bar\nend",
},
{
"syntax": "until",
"insert": "until foo do\nend\nfoo until done",
"replacement": "until foo\n bar\nend",
2016-10-27 00:32:08 +03:00
},
{
"syntax": "if",
"insert": "if foo\n bar\nelsif quux\n baz\nelse\n bat\nend",
"replacement": "if x\nend\nif y then\nend",
},
{
"syntax": "unless",
"insert": "unless foo\n bar\nelse\n bat\nend",
"replacement": "unless x\nend\nunless y then\nend",
},
{
"syntax": "if-unless-modifiers",
"insert": "print unless foo",
"replacement": "print if foo",
2016-10-27 01:22:59 +03:00
},
{
"syntax": "and-or",
"insert": "foo and bar",
"replacement": "foo or bar\na or b and c",
2016-10-27 01:44:53 +03:00
},
{
"syntax": "regex",
"insert": "/^(foo|bar[^_])$/i",
"replacement": "%r/a/\n%r<a<b>c>",
2016-10-27 18:30:34 +03:00
},
{
"syntax": "array",
"insert": "[ 1, 2, 3]",
"replacement": "['a', 'b', 'c']",
},
{
"syntax": "percent-array",
"insert": "%w(one two)",
"replacement": "%W(one #{b} three)",
2016-10-27 19:24:28 +03:00
},
{
"syntax": "lambda-dash-rocket",
"insert": "-> (a, b, c) {\n 1\n 2\n}",
"replacement": "-> { foo }",
},
{
"syntax": "lambda",
"insert": "lambda { foo }",
"replacement": "lambda { |x| x + 1 }",
2016-10-27 20:07:24 +03:00
},
{
"syntax": "for",
"insert": "for x in y\n f\nend",
"replacement": "for i in [1,2,3] do\n print i\nend",
},
{
"syntax": "element-reference",
"insert": "foo[bar]\nfoo[:bar]\nfoo[bar] = 1",
"replacement": "x[\"b\"]\nx[:\"c\"]",
},
{
"syntax": "control-statements",
"insert": "begin\n foo\nrescue x\n bar\nelse\n quux\nensure\n baz\nend",
"replacement": "begin\nend",
2016-10-19 20:33:21 +03:00
}
]
}
]