Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions spec/std/fiber/execution_context/global_queue_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe Fiber::ExecutionContext::GlobalQueue do

loop do
if fiber = queue.pop?
fc = fibers.find { |x| x.@fiber == fiber }.not_nil!
fc = fibers.find! { |x| x.@fiber == fiber }
queue.push(fiber) if fc.increment < increments
slept = 0
elsif slept < 100
Expand Down Expand Up @@ -163,7 +163,7 @@ describe Fiber::ExecutionContext::GlobalQueue do
}

execute = ->(fiber : Fiber) {
fc = fibers.find { |x| x.@fiber == fiber }.not_nil!
fc = fibers.find! { |x| x.@fiber == fiber }

if fc.increment < increments
batch.push(fc.@fiber)
Expand Down
2 changes: 1 addition & 1 deletion spec/std/fiber/execution_context/runnables_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ describe Fiber::ExecutionContext::Runnables do
slept = 0

execute = ->(fiber : Fiber) {
fc = fibers.find { |x| x.@fiber == fiber }.not_nil!
fc = fibers.find! { |x| x.@fiber == fiber }
runnables.push(fiber) if fc.increment < increments
}

Expand Down
4 changes: 2 additions & 2 deletions spec/std/regex_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,8 @@ describe "Regex" do
describe ".union" do
it "constructs a Regex that matches things any of its arguments match" do
re = Regex.union(/skiing/i, "sledding")
re.match("Skiing").not_nil![0].should eq "Skiing"
re.match("sledding").not_nil![0].should eq "sledding"
re.match!("Skiing")[0].should eq "Skiing"
re.match!("sledding")[0].should eq "sledding"
end

it "returns a regular expression that will match passed arguments" do
Expand Down
28 changes: 18 additions & 10 deletions spec/std/string_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2417,18 +2417,26 @@ describe "String" do
end
end

it "has match" do
"FooBar".match(/oo/).not_nil![0].should eq("oo")
end
describe "#match" do
it "has match" do
match = "FooBar".match(/oo/).should_not be_nil
match[0].should eq("oo")
end

it "matches with position" do
"こんにちは".match(/./, 1).not_nil![0].should eq("ん")
end
it "matches with position" do
match = "こんにちは".match(/./, 1).should_not be_nil
match[0].should eq("ん")
end

it "matches empty string" do
match = "".match(/.*/).not_nil!
match.group_size.should eq(0)
match[0].should eq("")
it "matches empty string" do
match = "".match(/.*/).should_not be_nil
match.group_size.should eq(0)
match[0].should eq("")
end

it "returns nil" do
"foo".match(/bar/).should be_nil
end
end

it "matches, but returns Bool" do
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/crystal/compiler.cr
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ module Crystal
if @progress_tracker.stats?
if result["reused"].as_bool
name = result["name"].as_s
unit = units.find { |unit| unit.name == name }.not_nil!
unit = units.find! { |unit| unit.name == name }
unit.reused_previous_compilation = true
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/crystal/crystal_path.cr
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ module Crystal

# Check if it's a wildcard.
if filename.ends_with?("/*") || (recursive = filename.ends_with?("/**"))
filename_dir_index = filename.rindex('/').not_nil!
filename_dir_index = filename.rindex!('/')
filename_dir = filename[0..filename_dir_index]
relative_dir = "#{relative_to}/#{filename_dir}"
if File.exists?(relative_dir)
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/crystal/tools/formatter.cr
Original file line number Diff line number Diff line change
Expand Up @@ -5111,7 +5111,7 @@ module Crystal
next if doc_comment.start_line > doc_comment.end_line

first_line = lines[doc_comment.start_line]
sharp_index = first_line.index('#').not_nil!
sharp_index = first_line.index!('#')

comment = String.build do |str|
(doc_comment.start_line..doc_comment.end_line).each do |i|
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/crystal/tools/playground/server.cr
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ module Crystal::Playground
public_dir = File.join(playground_dir, "public")

agent_ws = PathWebSocketHandler.new "/agent" do |ws, context|
match_data = context.request.path.not_nil!.match(/\/(\d+)\/(\d+)$/).not_nil!
match_data = context.request.path.not_nil!.match!(/\/(\d+)\/(\d+)$/)
session_key = match_data[1].to_i
tag = match_data[2].to_i
Log.info { "#{context.request.path} WebSocket connected (session=#{session_key}, tag=#{tag})" }
Expand Down