This documentation is automatically generated by online-judge-tools/verification-helper

:warning: spec/tuple/get_spec.cr

Depends on

Code

require "spec"
require "../../src/tuple/get"

describe Tuple do
  it "#_N" do
    a = {0}
    a._0.should eq 0
    b = {0, 1}
    b._0.should eq 0
    b._1.should eq 1
    c = {0, 1, 2}
    c._0.should eq 0
    c._1.should eq 1
    c._2.should eq 2
  end
end
require "spec"

# require "../../src/tuple/get"
struct Tuple
  macro method_missing(call)
    {% str = call.stringify %}
    {% if str =~ /_\d+/ %}
      self[{{ str[1...str.size].id }}]
    {% else %}
      {% raise call %}
    {% end %}
  end
end

describe Tuple do
  it "#_N" do
    a = {0}
    a._0.should eq 0
    b = {0, 1}
    b._0.should eq 0
    b._1.should eq 1
    c = {0, 1, 2}
    c._0.should eq 0
    c._1.should eq 1
    c._2.should eq 2
  end
end
Back to top page