Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assert("Enumerable#first") does not test Enumerable#first, tests Array#first #1905

Closed
suzukaze opened this issue Mar 21, 2014 · 0 comments
Closed

Comments

@suzukaze
Copy link
Contributor

I write a debug message in Enumerable#first method because I make sure that Enumerable#first is call in test.

mruby-enum-ext/mrblib/enum.rb

  def first(n=NONE)
    puts "first"

mruby-enum-ext/test/enum.rb

assert("Enumerable#first") do
  a = [1, 2, 3]
  assert_equal 1, a.first
  assert_equal [1, 2], a.first(2)
  assert_equal [1, 2, 3], a.first(10)
  assert_nil [].first
end

$ rake test

...
>>> Test host <<<
mrbtest - Embeddable Ruby Test

...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Total: 715
   OK: 715
   KO: 0
Crash: 0
 Time: 0.0601840 seconds

"first" is not displayed.

I change first method to first2 in Enumerable class.

mruby-enum-ext/mrblib/enum.rb

  def first2(n=NONE)
    puts "first"

mruby-enum-ext/test/enum.rb

assert("Enumerable#first") do
  a = [1, 2, 3]
  assert_equal 1, a.first2
  assert_equal [1, 2], a.first2(2)
  assert_equal [1, 2, 3], a.first2(10)
  assert_nil [].first2
end

$ rake test

...
>>> Test host <<<
mrbtest - Embeddable Ruby Test

..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
first
first
first
first
.............................................................................................................................
Total: 715
   OK: 715
   KO: 0
Crash: 0
 Time: 0.05197599999999 seconds

"first" is displayed.
Enumerable#first2 is tested.

@suzukaze suzukaze changed the title assert("Enumerable#first") is not testing Enumerable#first, Array#first assert("Enumerable#first") is not testing Enumerable#first, testing Array#first Mar 21, 2014
@suzukaze suzukaze changed the title assert("Enumerable#first") is not testing Enumerable#first, testing Array#first assert("Enumerable#first") does not test Enumerable#first, tests Array#first Mar 21, 2014
@matz matz closed this as completed in c978fd7 Mar 21, 2014
mattn pushed a commit to mattn/mruby that referenced this issue Sep 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant