Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: crystal-lang/crystal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 45e42a491952
Choose a base ref
...
head repository: crystal-lang/crystal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: dd15c0eaf52d
Choose a head ref
  • 4 commits
  • 7 files changed
  • 1 contributor

Commits on Jul 4, 2016

  1. File and IO::FileDescriptor inspect

    Ary Borenszweig committed Jul 4, 2016
    Copy the full SHA
    5bd34d6 View commit details
  2. Removed unused to_fd_io method

    Ary Borenszweig committed Jul 4, 2016
    Copy the full SHA
    2a014f6 View commit details
  3. compile -> build

    Ary Borenszweig committed Jul 4, 2016
    Copy the full SHA
    ff3733e View commit details
  4. Regex: use try instead of not_nil! in docs. Related to #2879

    Ary Borenszweig committed Jul 4, 2016
    Copy the full SHA
    dd15c0e View commit details
Showing with 30 additions and 24 deletions.
  1. +4 −4 Makefile
  2. +1 −1 bin/ci
  3. +5 −2 spec/std/file_spec.cr
  4. +0 −4 spec/std/io/buffered_spec.cr
  5. +1 −1 src/file.cr
  6. +9 −2 src/io/file_descriptor.cr
  7. +10 −10 src/regex.cr
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -59,19 +59,19 @@ deps: llvm_ext libcrystal

$(O)/all_spec: deps $(SOURCES) $(SPEC_SOURCES)
@mkdir -p $(O)
$(BUILD_PATH) ./bin/crystal compile $(FLAGS) -o $@ spec/all_spec.cr
$(BUILD_PATH) ./bin/crystal build $(FLAGS) -o $@ spec/all_spec.cr

$(O)/std_spec: deps $(SOURCES) $(SPEC_SOURCES)
@mkdir -p $(O)
$(BUILD_PATH) ./bin/crystal compile $(FLAGS) -o $@ spec/std_spec.cr
$(BUILD_PATH) ./bin/crystal build $(FLAGS) -o $@ spec/std_spec.cr

$(O)/compiler_spec: deps $(SOURCES) $(SPEC_SOURCES)
@mkdir -p $(O)
$(BUILD_PATH) ./bin/crystal compile $(FLAGS) -o $@ spec/compiler_spec.cr
$(BUILD_PATH) ./bin/crystal build $(FLAGS) -o $@ spec/compiler_spec.cr

$(O)/crystal: deps $(SOURCES)
@mkdir -p $(O)
$(BUILD_PATH) $(EXPORTS) ./bin/crystal compile $(FLAGS) -o $@ src/compiler/crystal.cr -D without_openssl -D without_zlib
$(BUILD_PATH) $(EXPORTS) ./bin/crystal build $(FLAGS) -o $@ src/compiler/crystal.cr -D without_openssl -D without_zlib

$(LLVM_EXT_OBJ): $(LLVM_EXT_DIR)/llvm_ext.cc
$(CXX) -c -o $@ $< `$(LLVM_CONFIG) --cxxflags`
2 changes: 1 addition & 1 deletion bin/ci
Original file line number Diff line number Diff line change
@@ -85,7 +85,7 @@ prepare_system() {
build() {
with_build_env 'make std_spec clean'
with_build_env 'make crystal std_spec compiler_spec doc'
with_build_env 'find samples -name "*.cr" | xargs -L 1 ./bin/crystal compile --no-codegen'
with_build_env 'find samples -name "*.cr" | xargs -L 1 ./bin/crystal build --no-codegen'
with_build_env './bin/crystal tool format --check'
}

7 changes: 5 additions & 2 deletions spec/std/file_spec.cr
Original file line number Diff line number Diff line change
@@ -410,7 +410,9 @@ describe "File" do
end

it "does to_s" do
File.new(__FILE__).to_s.should eq("#<File:#{__FILE__}>")
file = File.new(__FILE__)
file.to_s.should eq("#<File:0x#{file.object_id.to_s(16)}>")
File.new(__FILE__).inspect.should eq("#<File:#{__FILE__}>")
end

describe "close" do
@@ -434,7 +436,8 @@ describe "File" do
it "does to_s when closed" do
file = File.new(__FILE__)
file.close
file.to_s.should eq("#<File:#{__FILE__} (closed)>")
file.to_s.should eq("#<File:0x#{file.object_id.to_s(16)}>")
file.inspect.should eq("#<File:#{__FILE__} (closed)>")
end
end

4 changes: 0 additions & 4 deletions spec/std/io/buffered_spec.cr
Original file line number Diff line number Diff line change
@@ -44,10 +44,6 @@ class IO::BufferedWrapper
@io.closed?
end

def to_fd_io
@io.to_fd_io
end

private def unbuffered_rewind
@io.rewind
end
2 changes: 1 addition & 1 deletion src/file.cr
Original file line number Diff line number Diff line change
@@ -516,7 +516,7 @@ class File < IO::FileDescriptor
code
end

def to_s(io)
def inspect(io)
io << "#<File:" << @path
io << " (closed)" if closed?
io << ">"
11 changes: 9 additions & 2 deletions src/io/file_descriptor.cr
Original file line number Diff line number Diff line change
@@ -202,8 +202,15 @@ class IO::FileDescriptor
other
end

def to_fd_io
self
def inspect(io)
io << "#<IO::FileDescriptor:"
if closed?
io << "(closed)"
else
io << " fd=" << @fd
end
io << ">"
io
end

private def unbuffered_read(slice : Slice(UInt8))
20 changes: 10 additions & 10 deletions src/regex.cr
Original file line number Diff line number Diff line change
@@ -101,10 +101,10 @@ require "./regex/*"
# each capture group can be extracted on a successful match:
#
# ```
# /a(sd)f/.match("_asdf_") # => #<Regex::MatchData "asdf" 1:"sd">
# /a(sd)f/.match("_asdf_").not_nil![1] # => "sd"
# /a(?<grp>sd)f/.match("_asdf_") # => #<Regex::MatchData "asdf" grp:"sd">
# /a(?<grp>sd)f/.match("_asdf_").not_nil!["grp"] # => "sd"
# /a(sd)f/.match("_asdf_") # => #<Regex::MatchData "asdf" 1:"sd">
# /a(sd)f/.match("_asdf_").try &.[1] # => "sd"
# /a(?<grp>sd)f/.match("_asdf_") # => #<Regex::MatchData "asdf" grp:"sd">
# /a(?<grp>sd)f/.match("_asdf_").try &.["grp"] # => "sd"
# ```
#
# Capture groups are indexed starting from 1. Methods that accept a capture
@@ -405,9 +405,9 @@ class Regex
# `nil`. `$~` will contain the same value that was returned.
#
# ```
# /(.)(.)(.)/.match("abc").not_nil![2] # => "b"
# /(.)(.)/.match("abc", 1).not_nil![2] # => "c"
# /(.)(.)/.match("クリスタル", 3).not_nil![2] # => "ル"
# /(.)(.)(.)/.match("abc").try &.[2] # => "b"
# /(.)(.)/.match("abc", 1).try &.[2] # => "c"
# /(.)(.)/.match("クリスタル", 3).try &.[2] # => "ル"
# ```
def match(str, pos = 0, options = Regex::Options::None) : MatchData?
if byte_index = str.char_index_to_byte_index(pos)
@@ -425,9 +425,9 @@ class Regex
# `nil`. `$~` will contain the same value that was returned.
#
# ```
# /(.)(.)(.)/.match_at_byte_index("abc").not_nil![2] # => "b"
# /(.)(.)/.match_at_byte_index("abc", 1).not_nil![2] # => "c"
# /(.)(.)/.match_at_byte_index("クリスタル", 3).not_nil![2] # => "ス"
# /(.)(.)(.)/.match_at_byte_index("abc").try &.[2] # => "b"
# /(.)(.)/.match_at_byte_index("abc", 1).try &.[2] # => "c"
# /(.)(.)/.match_at_byte_index("クリスタル", 3).try &.[2] # => "ス"
# ```
def match_at_byte_index(str, byte_index = 0, options = Regex::Options::None) : MatchData?
return ($~ = nil) if byte_index > str.bytesize