Skip to content

Commit

Permalink
Annotate private to spec methods/classes more (#3892)
Browse files Browse the repository at this point in the history
  • Loading branch information
makenowjust authored and bcardiff committed Jan 17, 2017
1 parent aca9433 commit 1b97c99
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 52 deletions.
14 changes: 5 additions & 9 deletions spec/compiler/crystal/tools/context_spec.cr
@@ -1,10 +1,6 @@
require "spec"
require "yaml"
require "../../../../src/compiler/crystal/**"
require "../../../spec_helper"

include Crystal

def processed_context_visitor(code, cursor_location)
private def processed_context_visitor(code, cursor_location)
compiler = Compiler.new
compiler.no_codegen = true
result = compiler.compile(Compiler::Source.new(".", code), "fake-no-build")
Expand All @@ -15,7 +11,7 @@ def processed_context_visitor(code, cursor_location)
{visitor, process_result}
end

def run_context_tool(code)
private def run_context_tool(code)
cursor_location = nil

code.lines.each_with_index do |line, line_number_0|
Expand All @@ -35,7 +31,7 @@ def run_context_tool(code)
end
end

def assert_context_keys(code, *variables)
private def assert_context_keys(code, *variables)
run_context_tool(code) do |result|
result.contexts.should_not be_nil
result.contexts.not_nil!.each do |context|
Expand All @@ -44,7 +40,7 @@ def assert_context_keys(code, *variables)
end
end

def assert_context_includes(code, variable, var_types)
private def assert_context_includes(code, variable, var_types)
run_context_tool(code) do |result|
result.contexts.should_not be_nil
result.contexts.not_nil!.map { |h| h[variable].to_s }.should eq(var_types)
Expand Down
5 changes: 1 addition & 4 deletions spec/compiler/crystal/tools/expand_spec.cr
@@ -1,7 +1,4 @@
require "spec"
require "../../../../src/compiler/crystal/**"

include Crystal
require "../../../spec_helper"

private def processed_expand_visitor(code, cursor_location)
compiler = Compiler.new
Expand Down
10 changes: 3 additions & 7 deletions spec/compiler/crystal/tools/implementations_spec.cr
@@ -1,10 +1,6 @@
require "spec"
require "yaml"
require "../../../../src/compiler/crystal/**"
require "../../../spec_helper"

include Crystal

def processed_implementation_visitor(code, cursor_location)
private def processed_implementation_visitor(code, cursor_location)
compiler = Compiler.new
compiler.no_codegen = true
result = compiler.compile(Compiler::Source.new(".", code), "fake-no-build")
Expand All @@ -15,7 +11,7 @@ def processed_implementation_visitor(code, cursor_location)
{visitor, process_result}
end

def assert_implementations(code)
private def assert_implementations(code)
cursor_location = nil
expected_locations = [] of Location

Expand Down
6 changes: 3 additions & 3 deletions spec/compiler/crystal/tools/init_spec.cr
@@ -1,17 +1,17 @@
require "spec"
require "yaml"
require "compiler/crystal/tools/init"
require "compiler/crystal/config"
require "compiler/crystal/tools/init"

def describe_file(name, &block : String ->)
private def describe_file(name, &block : String ->)
describe name do
it "has proper contents" do
block.call(File.read("tmp/#{name}"))
end
end
end

def run_init_project(skeleton_type, name, dir, author, email, github_name)
private def run_init_project(skeleton_type, name, dir, author, email, github_name)
Crystal::Init::InitProject.new(
Crystal::Init::Config.new(skeleton_type, name, dir, author, email, github_name, true)
).run
Expand Down
18 changes: 5 additions & 13 deletions spec/compiler/crystal/tools/playground_spec.cr
@@ -1,8 +1,4 @@
require "spec"
require "yaml"
require "../../../../src/compiler/crystal/**"

include Crystal
require "../../../spec_helper"

private def instrument(source)
ast = Parser.new(source).parse
Expand All @@ -26,11 +22,11 @@ private def assert_agent_eq(source, expected)
instrument(source).should eq(expected)
end

class Crystal::Playground::Agent
@ws : HTTP::WebSocket | Crystal::Playground::TestAgent::FakeSocket
class Playground::Agent
@ws : HTTP::WebSocket | TestAgent::FakeSocket
end

class Crystal::Playground::TestAgent < Playground::Agent
private class TestAgent < Playground::Agent
class FakeSocket
property message

Expand All @@ -47,13 +43,9 @@ class Crystal::Playground::TestAgent < Playground::Agent
end
end

def a_sample_void
Pointer(Void).malloc(1_u64).value
end

describe Playground::Agent do
it "should send json messages and return inspected value" do
agent = Crystal::Playground::TestAgent.new(".", 32)
agent = TestAgent.new(".", 32)
agent.i(1) { 5 }.should eq(5)
agent.last_message.should eq(%({"tag":32,"type":"value","line":1,"value":"5","value_type":"Int32"}))
x, y = 3, 4
Expand Down
2 changes: 1 addition & 1 deletion spec/compiler/crystal/tools/table_print_spec.cr
@@ -1,7 +1,7 @@
require "spec"
require "compiler/crystal/tools/table_print"

def assert_table(expected)
private def assert_table(expected)
actual = String::Builder.build do |builder|
Crystal::TablePrint.new(builder).build do |tp|
with tp yield
Expand Down
4 changes: 2 additions & 2 deletions spec/std/http/cookie_spec.cr
@@ -1,13 +1,13 @@
require "spec"
require "http/cookie"

def parse_first_cookie(header)
private def parse_first_cookie(header)
cookies = HTTP::Cookie::Parser.parse_cookies(header)
cookies.size.should eq(1)
cookies.first
end

def parse_set_cookie(header)
private def parse_set_cookie(header)
cookie = HTTP::Cookie::Parser.parse_set_cookie(header)
cookie.should_not be_nil
cookie.not_nil!
Expand Down
2 changes: 1 addition & 1 deletion spec/std/indexable_spec.cr
@@ -1,6 +1,6 @@
require "spec"

class SafeIndexable
private class SafeIndexable
include Indexable(Int32)

getter size
Expand Down
2 changes: 1 addition & 1 deletion spec/std/openssl/ssl/hostname_validation_spec.cr
@@ -1,7 +1,7 @@
require "spec"
require "openssl/ssl/hostname_validation"

def openssl_create_cert(subject = nil, san = nil)
private def openssl_create_cert(subject = nil, san = nil)
cert = OpenSSL::X509::Certificate.new
cert.subject = subject if subject
cert.add_extension(OpenSSL::X509::Extension.new("subjectAltName", san)) if san
Expand Down
8 changes: 4 additions & 4 deletions spec/std/random_spec.cr
@@ -1,6 +1,6 @@
require "spec"

class TestRNG(T)
private class TestRNG(T)
include Random

def initialize(@data : Array(T))
Expand All @@ -18,9 +18,9 @@ class TestRNG(T)
end
end

RNG_DATA_8 = [234u8, 153u8, 0u8, 0u8, 127u8, 128u8, 255u8, 255u8]
RNG_DATA_32 = [31541451u32, 0u32, 1u32, 234u32, 342475672u32, 863u32, 0xffffffffu32, 50967465u32]
RNG_DATA_64 = [148763248732657823u64, 18446744073709551615u64, 0u64,
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]

Expand Down
2 changes: 1 addition & 1 deletion spec/std/record_spec.cr
@@ -1,6 +1,6 @@
require "spec"

module RecordSpec
private module RecordSpec
record Record1,
x : Int32,
y : Array(Int32)
Expand Down
2 changes: 1 addition & 1 deletion spec/std/reference_spec.cr
@@ -1,6 +1,6 @@
require "spec"

module ReferenceSpec
private module ReferenceSpec
class TestClass
@x : Int32
@y : String
Expand Down
4 changes: 2 additions & 2 deletions spec/std/spec/junit_formatter_spec.cr
Expand Up @@ -118,15 +118,15 @@ describe "JUnit Formatter" do
end
end

def build_report
private def build_report
output = String::Builder.new
formatter = Spec::JUnitFormatter.new(output)
yield formatter
formatter.finish
output.to_s
end

def exception_with_backtrace(msg)
private def exception_with_backtrace(msg)
begin
raise Exception.new(msg)
rescue e
Expand Down
2 changes: 1 addition & 1 deletion spec/std/spec_spec.cr
@@ -1,6 +1,6 @@
require "spec"

class SpecException < Exception
private class SpecException < Exception
getter value : Int32

def initialize(@value, msg)
Expand Down
2 changes: 1 addition & 1 deletion spec/std/struct_spec.cr
@@ -1,7 +1,7 @@
require "spec"
require "big_int"

module StructSpec
private module StructSpec
struct TestClass
@x : Int32
@y : String
Expand Down
2 changes: 1 addition & 1 deletion spec/std/time/time_spec.cr
@@ -1,6 +1,6 @@
require "spec"

TimeSpecTicks = [
private TimeSpecTicks = [
631501920000000000_i64, # 25 Feb 2002 - 00:00:00
631502475130080000_i64, # 25 Feb 2002 - 15:25:13,8
631502115130080000_i64, # 25 Feb 2002 - 05:25:13,8
Expand Down

0 comments on commit 1b97c99

Please sign in to comment.