Skip to content

Commit

Permalink
#3915 Apply formatter changes to compiler source code
Browse files Browse the repository at this point in the history
  • Loading branch information
juanedi authored and Santiago Palladino committed Feb 10, 2017
1 parent 2188113 commit dff9b2e
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 33 deletions.
34 changes: 17 additions & 17 deletions spec/compiler/lexer/lexer_spec.cr
Expand Up @@ -126,22 +126,22 @@ describe "Lexer" do
it_lexes "\n\n\n", :NEWLINE
it_lexes "_", :UNDERSCORE
it_lexes_keywords [:def, :if, :else, :elsif, :end, :true, :false, :class, :module, :include,
:extend, :while, :until, :nil, :do, :yield, :return, :unless, :next, :break,
:begin, :lib, :fun, :type, :struct, :union, :enum, :macro, :out, :require,
:case, :when, :select, :then, :of, :abstract, :rescue, :ensure, :is_a?, :alias,
:pointerof, :sizeof, :instance_sizeof, :as, :as?, :typeof, :for, :in,
:with, :self, :super, :private, :protected, :asm, :uninitialized, :nil?]
:extend, :while, :until, :nil, :do, :yield, :return, :unless, :next, :break,
:begin, :lib, :fun, :type, :struct, :union, :enum, :macro, :out, :require,
:case, :when, :select, :then, :of, :abstract, :rescue, :ensure, :is_a?, :alias,
:pointerof, :sizeof, :instance_sizeof, :as, :as?, :typeof, :for, :in,
:with, :self, :super, :private, :protected, :asm, :uninitialized, :nil?]
it_lexes_idents ["ident", "something", "with_underscores", "with_1", "foo?", "bar!", "fooBar",
"❨╯°□°❩╯︵┻━┻"]
"❨╯°□°❩╯︵┻━┻"]
it_lexes_idents ["def?", "if?", "else?", "elsif?", "end?", "true?", "false?", "class?", "while?",
"do?", "yield?", "return?", "unless?", "next?", "break?", "begin?"]
"do?", "yield?", "return?", "unless?", "next?", "break?", "begin?"]
it_lexes_idents ["def!", "if!", "else!", "elsif!", "end!", "true!", "false!", "class!", "while!",
"nil!", "do!", "yield!", "return!", "unless!", "next!", "break!", "begin!"]
"nil!", "do!", "yield!", "return!", "unless!", "next!", "break!", "begin!"]
it_lexes_i32 ["1", ["0i32", "0"], ["1hello", "1"], "+1", "-1", "1234", "+1234", "-1234",
["1.foo", "1"], ["1_000", "1000"], ["100_000", "100000"]]
["1.foo", "1"], ["1_000", "1000"], ["100_000", "100000"]]
it_lexes_i64 [["1i64", "1"], ["1_i64", "1"], ["1i64hello", "1"], ["+1_i64", "+1"], ["-1_i64", "-1"]]
it_lexes_f32 [["0f32", "0"], ["0_f32", "0"], ["1.0f32", "1.0"], ["1.0f32hello", "1.0"],
["+1.0f32", "+1.0"], ["-1.0f32", "-1.0"], ["-0.0f32", "-0.0"], ["1_234.567_890_f32", "1234.567890"]]
["+1.0f32", "+1.0"], ["-1.0f32", "-1.0"], ["-0.0f32", "-0.0"], ["1_234.567_890_f32", "1234.567890"]]
it_lexes_f64 ["1.0", ["1.0hello", "1.0"], "+1.0", "-1.0", ["1_234.567_890", "1234.567890"]]
it_lexes_f32 [["1e+23_f32", "1e+23"], ["1.2e+23_f32", "1.2e+23"]]
it_lexes_f64 ["1e23", "1e-23", "1e+23", "1.2e+23", ["1e23f64", "1e23"], ["1.2e+23_f64", "1.2e+23"]]
Expand Down Expand Up @@ -229,11 +229,11 @@ describe "Lexer" do
assert_syntax_error "'", "unterminated char literal"
assert_syntax_error "'\\", "unterminated char literal"
it_lexes_operators [:"=", :"<", :"<=", :">", :">=", :"+", :"-", :"*", :"(", :")",
:"==", :"!=", :"=~", :"!", :",", :".", :"..", :"...", :"&&", :"||",
:"|", :"{", :"}", :"?", :":", :"+=", :"-=", :"*=", :"%=", :"&=",
:"|=", :"^=", :"**=", :"<<", :">>", :"%", :"&", :"|", :"^", :"**", :"<<=",
:">>=", :"~", :"[]", :"[]=", :"[", :"]", :"::", :"<=>", :"=>", :"||=",
:"&&=", :"===", :";", :"->", :"[]?", :"{%", :"{{", :"%}", :"@[", :"!~"]
:"==", :"!=", :"=~", :"!", :",", :".", :"..", :"...", :"&&", :"||",
:"|", :"{", :"}", :"?", :":", :"+=", :"-=", :"*=", :"%=", :"&=",
:"|=", :"^=", :"**=", :"<<", :">>", :"%", :"&", :"|", :"^", :"**", :"<<=",
:">>=", :"~", :"[]", :"[]=", :"[", :"]", :"::", :"<=>", :"=>", :"||=",
:"&&=", :"===", :";", :"->", :"[]?", :"{%", :"{{", :"%}", :"@[", :"!~"]
it_lexes "!@foo", :"!"
it_lexes "+@foo", :"+"
it_lexes "-@foo", :"-"
Expand All @@ -242,8 +242,8 @@ describe "Lexer" do
it_lexes_class_var "@@foo"
it_lexes_globals ["$foo", "$FOO", "$_foo", "$foo123"]
it_lexes_symbols [":foo", ":foo!", ":foo?", ":\"foo\"", ":かたな", ":+", ":-", ":*", ":/",
":==", ":<", ":<=", ":>", ":>=", ":!", ":!=", ":=~", ":!~", ":&", ":|",
":^", ":~", ":**", ":>>", ":<<", ":%", ":[]", ":[]?", ":[]=", ":<=>", ":===",
":==", ":<", ":<=", ":>", ":>=", ":!", ":!=", ":=~", ":!~", ":&", ":|",
":^", ":~", ":**", ":>>", ":<<", ":%", ":[]", ":[]?", ":[]=", ":<=>", ":===",
]
it_lexes_global_match_data_index ["$1", "$10", "$1?", "$23?"]

Expand Down
4 changes: 2 additions & 2 deletions spec/compiler/parser/parser_spec.cr
Expand Up @@ -58,8 +58,8 @@ describe "Parser" do
it_parses %(%q{hello \#{foo} world}), "hello \#{foo} world".string

[":foo", ":foo!", ":foo?", ":\"foo\"", ":かたな", ":+", ":-", ":*", ":/", ":==", ":<", ":<=", ":>",
":>=", ":!", ":!=", ":=~", ":!~", ":&", ":|", ":^", ":~", ":**", ":>>", ":<<", ":%", ":[]", ":[]?",
":[]=", ":<=>", ":==="].each do |symbol|
":>=", ":!", ":!=", ":=~", ":!~", ":&", ":|", ":^", ":~", ":**", ":>>", ":<<", ":%", ":[]", ":[]?",
":[]=", ":<=>", ":==="].each do |symbol|
value = symbol[1, symbol.size - 1]
value = value[1, value.size - 2] if value.starts_with?("\"")
it_parses symbol, value.symbol
Expand Down
16 changes: 8 additions & 8 deletions spec/std/base64_spec.cr
Expand Up @@ -5,8 +5,8 @@ require "crypto/md5"
describe "Base64" do
context "simple test" do
eqs = {"" => "", "a" => "YQ==\n", "ab" => "YWI=\n", "abc" => "YWJj\n",
"abcd" => "YWJjZA==\n", "abcde" => "YWJjZGU=\n", "abcdef" => "YWJjZGVm\n",
"abcdefg" => "YWJjZGVmZw==\n"}
"abcd" => "YWJjZA==\n", "abcde" => "YWJjZGU=\n", "abcdef" => "YWJjZGVm\n",
"abcdefg" => "YWJjZGVmZw==\n"}
eqs.each do |a, b|
it "encode #{a.inspect} to #{b.inspect}" do
Base64.encode(a).should eq(b)
Expand All @@ -20,7 +20,7 @@ describe "Base64" do

context "\n in multiple places" do
eqs = {"abcd" => "YWJj\nZA==\n", "abcde" => "YWJj\nZGU=\n", "abcdef" => "YWJj\nZGVm\n",
"abcdefg" => "YWJj\nZGVmZw==\n", "abcdefg" => "YWJj\nZGVm\nZw==\n",
"abcdefg" => "YWJj\nZGVmZw==\n", "abcdefg" => "YWJj\nZGVm\nZw==\n",
}
eqs.each do |a, b|
it "decode from #{b.inspect} to #{a.inspect}" do
Expand All @@ -45,9 +45,9 @@ describe "Base64" do

describe "base" do
eqs = {"Send reinforcements" => "U2VuZCByZWluZm9yY2VtZW50cw==\n",
"Now is the time for all good coders\nto learn Crystal" => "Tm93IGlzIHRoZSB0aW1lIGZvciBhbGwgZ29vZCBjb2RlcnMKdG8gbGVhcm4g\nQ3J5c3RhbA==\n",
"This is line one\nThis is line two\nThis is line three\nAnd so on...\n" => "VGhpcyBpcyBsaW5lIG9uZQpUaGlzIGlzIGxpbmUgdHdvClRoaXMgaXMgbGlu\nZSB0aHJlZQpBbmQgc28gb24uLi4K\n",
"hahah⊙ⓧ⊙" => "aGFoYWjiipnik6fiipk=\n"}
"Now is the time for all good coders\nto learn Crystal" => "Tm93IGlzIHRoZSB0aW1lIGZvciBhbGwgZ29vZCBjb2RlcnMKdG8gbGVhcm4g\nQ3J5c3RhbA==\n",
"This is line one\nThis is line two\nThis is line three\nAnd so on...\n" => "VGhpcyBpcyBsaW5lIG9uZQpUaGlzIGlzIGxpbmUgdHdvClRoaXMgaXMgbGlu\nZSB0aHJlZQpBbmQgc28gb24uLi4K\n",
"hahah⊙ⓧ⊙" => "aGFoYWjiipnik6fiipk=\n"}
eqs.each do |a, b|
it "encode #{a.inspect} to #{b.inspect}" do
Base64.encode(a).should eq(b)
Expand Down Expand Up @@ -106,8 +106,8 @@ describe "Base64" do
it "decode \n in multiple places" do
decoded = "hahah⊙ⓧ⊙"
{"aGFoYWjiipnik6fiipk=", "aGFo\nYWjiipnik6fiipk=", "aGFo\nYWji\nipnik6fiipk=",
"aGFo\nYWji\nipni\nk6fiipk=", "aGFo\nYWji\nipni\nk6fi\nipk=",
"aGFo\nYWji\nipni\nk6fi\nipk=\n"}.each do |encoded|
"aGFo\nYWji\nipni\nk6fiipk=", "aGFo\nYWji\nipni\nk6fi\nipk=",
"aGFo\nYWji\nipni\nk6fi\nipk=\n"}.each do |encoded|
Base64.decode(encoded).should eq(decoded.to_slice)
Base64.decode_string(encoded).should eq(decoded)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/std/enumerable_spec.cr
Expand Up @@ -460,7 +460,7 @@ describe "Enumerable" do

it "groups can group by size (like the doc example)" do
%w(Alice Bob Ary).group_by { |e| e.size }.should eq({3 => ["Bob", "Ary"],
5 => ["Alice"]})
5 => ["Alice"]})
end
end

Expand Down
8 changes: 4 additions & 4 deletions spec/std/random_spec.cr
Expand Up @@ -21,8 +21,8 @@ end
private RNG_DATA_8 = [234u8, 153u8, 0u8, 0u8, 127u8, 128u8, 255u8, 255u8]
private RNG_DATA_32 = [31541451u32, 0u32, 1u32, 234u32, 342475672u32, 863u32, 0xffffffffu32, 50967465u32]
private RNG_DATA_64 = [148763248732657823u64, 18446744073709551615u64, 0u64,
32456325635673576u64, 2456245614625u64, 32452456246u64, 3956529762u64,
9823674982364u64, 234253464546456u64, 14345435645646u64]
32456325635673576u64, 2456245614625u64, 32452456246u64, 3956529762u64,
9823674982364u64, 234253464546456u64, 14345435645646u64]

describe "Random" do
it "limited number" do
Expand Down Expand Up @@ -58,7 +58,7 @@ describe "Random" do

it "does with inclusive range" do
[1..1, 1..3, 0u8..255u8, -1..1, Int64::MIN..7i64,
-7i64..Int64::MAX, 0u64..0u64].each do |range|
-7i64..Int64::MAX, 0u64..0u64].each do |range|
x = rand(range)
x.should be >= range.begin
x.should be <= range.end
Expand All @@ -67,7 +67,7 @@ describe "Random" do

it "does with exclusive range" do
[1...2, 1...4, 0u8...255u8, -1...1, Int64::MIN...7i64,
-7i64...Int64::MAX, -1i8...0i8].each do |range|
-7i64...Int64::MAX, -1i8...0i8].each do |range|
x = rand(range)
x.should be >= range.begin
x.should be < range.end
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/crystal/tools/doc/generator.cr
Expand Up @@ -159,7 +159,7 @@ class Crystal::Doc::Generator
return false unless type.namespace == crystal_type

{"BUILD_COMMIT", "BUILD_DATE", "CACHE_DIR", "DEFAULT_PATH",
"DESCRIPTION", "PATH", "VERSION"}.each do |name|
"DESCRIPTION", "PATH", "VERSION"}.each do |name|
return true if type == crystal_type.types[name]?
end

Expand Down

0 comments on commit dff9b2e

Please sign in to comment.