[#237] object.c ruby.h (fwd) — Robert Skarwecki <skaav@...>

Hello everybody,

42 messages 2002/07/24
[#239] Re: [PATCH] object.c ruby.h (fwd) — GOTO Kentaro <gotoken@...> 2002/07/24

At Thu, 25 Jul 2002 00:02:28 +0900,

[#240] Re: [PATCH] object.c ruby.h (fwd) — Dave Thomas <Dave@...> 2002/07/24

GOTO Kentaro <gotoken@notwork.org> writes:

[#246] Re: [PATCH] object.c ruby.h (fwd) — GOTO Kentaro <gotoken@...> 2002/07/25

At Thu, 25 Jul 2002 05:05:46 +0900,

[#247] Re: [PATCH] object.c ruby.h (fwd) — Dave Thomas <Dave@...> 2002/07/25

GOTO Kentaro <gotoken@notwork.org> writes:

[#248] Re: [PATCH] object.c ruby.h (fwd) — nobu.nokada@... 2002/07/25

Hi,

[#249] Re: [PATCH] object.c ruby.h (fwd) — Dave Thomas <Dave@...> 2002/07/25

nobu.nokada@softhome.net writes:

[#250] Re: [PATCH] object.c ruby.h (fwd) — nobu.nokada@... 2002/07/25

Hi,

[#252] Re: [PATCH] object.c ruby.h (fwd) — GOTO Kentaro <gotoken@...> 2002/07/25

At Fri, 26 Jul 2002 03:11:02 +0900,

[#253] Re: [PATCH] object.c ruby.h (fwd) — Dave Thomas <Dave@...> 2002/07/25

GOTO Kentaro <gotoken@notwork.org> writes:

Re: [PATCH] object.c ruby.h (fwd)

From: GOTO Kentaro <gotoken@...>
Date: 2002-07-25 22:23:15 UTC
List: ruby-core #255
At Fri, 26 Jul 2002 05:34:10 +0900,
Dave Thomas wrote:
> If you call Regexp#match with a non-string argument, it calls that
> argument's to_str method to coerce it into a string.
> 
> So, perhaps, if the expression to pass to 'if', 'while', and friends
> isn't 'true' or 'false', the interpreter should call #truth? on it to
> coerce it into a truth value.[1]

Oops! Sorry, I misunderstood that `and' or `or' treat conditions as
same as `if' or `while' do.  Now I agree your opinion but would like
to withdraw proposition to introduce anything built-in to obtain truth
value for each object.  The truth is not simple indeed.

  % ruby17 -e '$_ = "foo"; /x/ or puts :pass' 
  % ruby17 -e '$_ = "foo"; puts :pass unless /x/' 
  pass
  % ruby17 -v
  ruby 1.7.2 (2002-07-13) [i386-freebsd4.5]

By the way, how about asking the auther to fit the behavior of
RubyUnit's assert() to Test::Unit's?

  % ruby ~/foo.rb
  Test::Unit ------------------------------
  Loaded suite TestTU
  Started...
  .
  Finished in 0.003085 seconds.
  1 runs, 1 assertions, 0 failures, 0 errors
  RubyUnit ------------------------------

  TestRU#test_x E.
  Time: 0.177137
  FAILURES!!!
  Test Results:
   Run: 1/1(1 asserts) Failures: 0 Errors: 1
  Errors: 1
  /home/gotoken/foo.rb:21:in `test_x'(TestRU): 1st argument <1> type should be TrueClass or FalseClass. (TypeError)
          from /home/gotoken/foo.rb:25
  % cat ~/foo.rb
  puts "Test::Unit ------------------------------"

  require "test/unit"
  require "test/unit/ui/console/testrunner"

  class TestTU < Test::Unit::TestCase
    def test_x
      assert(1)
    end
  end

  Test::Unit::UI::Console::TestRunner.run(TestTU)

  puts "RubyUnit ------------------------------"

  require "runit/testcase"
  require "runit/cui/testrunner"

  class TestRU < RUNIT::TestCase
    def test_x
      assert(1)
    end
  end

  RUNIT::CUI::TestRunner.run(TestRU.suite)

  % 

-- Gotoken

In This Thread