Re: [MacRuby-devel] calculate table row height

2010-06-23 Thread niedhui
thank you,it helps a lot
On Jun 22, 2010, at 3:46 PM, Jakub Suder wrote:

> One warning, it uses blocks, so if you want to use it on 10.5, you'd
> have to make a few changes in it.
> 
> JS
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


[MacRuby-devel] My Current UI Testing Setup

2010-06-23 Thread Ryan Davis
Here is my current macruby UI testing setup:

Rakefile:

+ Has an isolate setup to pull down all my testing gems.
+ task build - runs xcodebuild to build a debug app
+ task link  - runs a build and then hard links source files to build
   files

~/.emacs.el:

+ sets 'backup-by-copying-when-linked to t - allowing work on
  hardlinked files to go unimpeded.

.autotest:

+ Sets ENV['RUBY'] to macruby.
+ Sets ENV['MACRUBY_TESTING'] to 1.
+ Sets ENV['GEM_HOME'] and ENV['GEM_PATH'] with expanded paths to pick
  up isolated gems during test runs.
+ initialize hook sets the test framework to minitest and runs the
  link rake task.
+ Overrides Autotest#make_test_cmd to execute the binary directly.

lib/app_controller.rb:

+ sets $TESTING = ENV['MACRUBY_TESTING']
+ applicationDidFinishLaunching requires minitest/macruby if $TESTING

rb_main.rb:

+ needed to be tweaked to skip loading test files.

So, when I fire up autotest it will build the application and then
hardlink all the original source files into the build. This allows
autotest to scan the lib and test dirs but invoking the application
will pick up all my changes without having to rebuild. This greatly
speeds up development.

When autotest runs the application directly, it does so with
MACRUBY_TESTING set in the environment. The application sees this and
sets $TESTING to true and once the app is done launching, it loads
minitest/macruby. That in turn loads up all the test files in the
build dir and then runs the tests. Once the tests are run, it exits
with the appropriate exit code depending on test results.


___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


[MacRuby-devel] My MiniTest extensions for macruby

2010-06-23 Thread Ryan Davis
> class MiniTest::Unit
>   def self.run_macruby_tests
> 
> module MiniTest::Assertions
>   def find_ui_menu(*path)
>   def find_ui_menu_items menu
>   def assert_ui_menu menu, *items
>   def find_ui_menu_item(*path)
>   def assert_ui_action obj, target, action, key = nil
>   def assert_ui_binding item, binding_name, target, path

Allowing me to write tests like:

>   def test_ui_wirings
> app = NSApplication.sharedApplication
> delegate = app.delegate
> 
> assert_kind_of AppController,delegate
> assert_kind_of NSWindow, delegate.window
> assert_kind_of NSOutlineView,delegate.sidebar
> assert_kind_of NSTextField,  delegate.label
> assert_kind_of NSCollectionView, delegate.files
> 
> assert_ui_menu("File",
>"Restart Triage",
>"Empty Triage",
>"Update",
>"",
>"Reveal",
>"Group",
>"Ungroup",
>"Move to Triage",
>"Move to Trash")
> 
> has_selection = "sidebar.numberOfSelectedRows"
> 
> restart, empty, update, _, reveal, group, ungroup, triage, trash =
>   find_ui_menu_items "File"
> 
> assert_ui_action restart, delegate, "restart:", ""
> 
> assert_ui_action empty, delegate, "empty:"
> 
> assert_ui_action update, delegate, "update:", "u"
> 
> assert_ui_action  reveal, delegate, "reveal:", "r"
> assert_ui_binding reveal, :enabled, delegate, has_selection
> 
> assert_ui_action  triage, delegate, "triage:", "t"
> assert_ui_binding triage, :enabled, delegate, has_selection
> 
> assert_ui_action group, delegate, "group:"
> assert_ui_binding group,  :enabled, delegate, has_selection
> 
> # TODO: make it properly toggle later
> assert_ui_action ungroup, delegate, "ungroup:"
> assert_ui_binding ungroup, :enabled, delegate, has_selection
> 
> assert_ui_action  trash, delegate, "trash:"
> assert_ui_binding trash,  :enabled, delegate, has_selection
>   end
> 
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] My Current UI Testing Setup

2010-06-23 Thread Matt Aimonetti
That's a really cool setup Ryan. Would you mind explaining a bit more about
what you are testing and how you ares testing?

Thanks,

- Matt

On Wed, Jun 23, 2010 at 12:15 PM, Ryan Davis wrote:

> Here is my current macruby UI testing setup:
>
> Rakefile:
>
> + Has an isolate setup to pull down all my testing gems.
> + task build - runs xcodebuild to build a debug app
> + task link  - runs a build and then hard links source files to build
>   files
>
> ~/.emacs.el:
>
> + sets 'backup-by-copying-when-linked to t - allowing work on
>  hardlinked files to go unimpeded.
>
> .autotest:
>
> + Sets ENV['RUBY'] to macruby.
> + Sets ENV['MACRUBY_TESTING'] to 1.
> + Sets ENV['GEM_HOME'] and ENV['GEM_PATH'] with expanded paths to pick
>  up isolated gems during test runs.
> + initialize hook sets the test framework to minitest and runs the
>  link rake task.
> + Overrides Autotest#make_test_cmd to execute the binary directly.
>
> lib/app_controller.rb:
>
> + sets $TESTING = ENV['MACRUBY_TESTING']
> + applicationDidFinishLaunching requires minitest/macruby if $TESTING
>
> rb_main.rb:
>
> + needed to be tweaked to skip loading test files.
>
> So, when I fire up autotest it will build the application and then
> hardlink all the original source files into the build. This allows
> autotest to scan the lib and test dirs but invoking the application
> will pick up all my changes without having to rebuild. This greatly
> speeds up development.
>
> When autotest runs the application directly, it does so with
> MACRUBY_TESTING set in the environment. The application sees this and
> sets $TESTING to true and once the app is done launching, it loads
> minitest/macruby. That in turn loads up all the test files in the
> build dir and then runs the tests. Once the tests are run, it exits
> with the appropriate exit code depending on test results.
>
>
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] My Current UI Testing Setup

2010-06-23 Thread Matt Aimonetti
Nevermind, I just saw your other post. Really nice, thanks for sharing.

- Matt

On Wed, Jun 23, 2010 at 12:22 PM, Matt Aimonetti wrote:

> That's a really cool setup Ryan. Would you mind explaining a bit more about
> what you are testing and how you ares testing?
>
> Thanks,
>
> - Matt
>
>
> On Wed, Jun 23, 2010 at 12:15 PM, Ryan Davis wrote:
>
>> Here is my current macruby UI testing setup:
>>
>> Rakefile:
>>
>> + Has an isolate setup to pull down all my testing gems.
>> + task build - runs xcodebuild to build a debug app
>> + task link  - runs a build and then hard links source files to build
>>   files
>>
>> ~/.emacs.el:
>>
>> + sets 'backup-by-copying-when-linked to t - allowing work on
>>  hardlinked files to go unimpeded.
>>
>> .autotest:
>>
>> + Sets ENV['RUBY'] to macruby.
>> + Sets ENV['MACRUBY_TESTING'] to 1.
>> + Sets ENV['GEM_HOME'] and ENV['GEM_PATH'] with expanded paths to pick
>>  up isolated gems during test runs.
>> + initialize hook sets the test framework to minitest and runs the
>>  link rake task.
>> + Overrides Autotest#make_test_cmd to execute the binary directly.
>>
>> lib/app_controller.rb:
>>
>> + sets $TESTING = ENV['MACRUBY_TESTING']
>> + applicationDidFinishLaunching requires minitest/macruby if $TESTING
>>
>> rb_main.rb:
>>
>> + needed to be tweaked to skip loading test files.
>>
>> So, when I fire up autotest it will build the application and then
>> hardlink all the original source files into the build. This allows
>> autotest to scan the lib and test dirs but invoking the application
>> will pick up all my changes without having to rebuild. This greatly
>> speeds up development.
>>
>> When autotest runs the application directly, it does so with
>> MACRUBY_TESTING set in the environment. The application sees this and
>> sets $TESTING to true and once the app is done launching, it loads
>> minitest/macruby. That in turn loads up all the test files in the
>> build dir and then runs the tests. Once the tests are run, it exits
>> with the appropriate exit code depending on test results.
>>
>>
>> ___
>> MacRuby-devel mailing list
>> [email protected]
>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>>
>
>
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] My MiniTest extensions for macruby

2010-06-23 Thread Ryan Davis

On Jun 23, 2010, at 12:21 , Ryan Davis wrote:

>> class MiniTest::Unit
>>  def self.run_macruby_tests
>> 
>> module MiniTest::Assertions
>>  def find_ui_menu(*path)
>>  def find_ui_menu_items menu
>>  def assert_ui_menu menu, *items
>>  def find_ui_menu_item(*path)
>>  def assert_ui_action obj, target, action, key = nil
>>  def assert_ui_binding item, binding_name, target, path

I'm torn between releasing this as part of minitest or releasing it under a new 
gem called minitest-macruby (or something).

I'd also love to see more ideas for assertions and helper methods and the 
like... the more the merrier.

___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] My MiniTest extensions for macruby

2010-06-23 Thread Matt Aimonetti
I'd suggest to release a new gem.

- Matt

On Wed, Jun 23, 2010 at 1:05 PM, Ryan Davis wrote:

>
> On Jun 23, 2010, at 12:21 , Ryan Davis wrote:
>
> >> class MiniTest::Unit
> >>  def self.run_macruby_tests
> >>
> >> module MiniTest::Assertions
> >>  def find_ui_menu(*path)
> >>  def find_ui_menu_items menu
> >>  def assert_ui_menu menu, *items
> >>  def find_ui_menu_item(*path)
> >>  def assert_ui_action obj, target, action, key = nil
> >>  def assert_ui_binding item, binding_name, target, path
>
> I'm torn between releasing this as part of minitest or releasing it under a
> new gem called minitest-macruby (or something).
>
> I'd also love to see more ideas for assertions and helper methods and the
> like... the more the merrier.
>
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] My MiniTest extensions for macruby

2010-06-23 Thread Ryan Davis

On Jun 23, 2010, at 13:13 , Matt Aimonetti wrote:

> I'd suggest to release a new gem.

yeah... but the reason why I'm torn is that if it goes into minitest directly, 
it goes into macruby directly... easy-peasy for everyone.

___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] My MiniTest extensions for macruby

2010-06-23 Thread Matt Aimonetti
I think we should just ship your gem with MacRuby, Laurent, what do you
think?

- Matt

On Wed, Jun 23, 2010 at 1:19 PM, Ryan Davis wrote:

>
> On Jun 23, 2010, at 13:13 , Matt Aimonetti wrote:
>
> > I'd suggest to release a new gem.
>
> yeah... but the reason why I'm torn is that if it goes into minitest
> directly, it goes into macruby directly... easy-peasy for everyone.
>
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] My MiniTest extensions for macruby

2010-06-23 Thread Laurent Sansonetti
Looks like it would make sense to bundle this in MacRuby directly, since these 
are extensions. This way it's easily available to everyone. 

Ryan, would you be willing to commit & maintain these bits in our SVN 
repository if we give you access?

Laurent

On Jun 23, 2010, at 1:25 PM, Matt Aimonetti wrote:

> I think we should just ship your gem with MacRuby, Laurent, what do you think?
> 
> - Matt
> 
> On Wed, Jun 23, 2010 at 1:19 PM, Ryan Davis  wrote:
> 
> On Jun 23, 2010, at 13:13 , Matt Aimonetti wrote:
> 
> > I'd suggest to release a new gem.
> 
> yeah... but the reason why I'm torn is that if it goes into minitest 
> directly, it goes into macruby directly... easy-peasy for everyone.
> 
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
> 
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] My MiniTest extensions for macruby

2010-06-23 Thread Ryan Davis

On Jun 23, 2010, at 13:31 , Laurent Sansonetti wrote:

> Ryan, would you be willing to commit & maintain these bits in our SVN 
> repository if we give you access?

but of course. seems only fair.

___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


[MacRuby-devel] [MacRuby] #761: Integer 2 multiplication by self seems wrong

2010-06-23 Thread MacRuby
#761: Integer 2  multiplication by self seems wrong
--+-
 Reporter:  ustc.li...@…  |   Owner:  lsansone...@…
 Type:  defect|  Status:  new  
 Priority:  blocker   |   Milestone:  MacRuby 0.6  
Component:  MacRuby   |Keywords:  multiply 2   
--+-
 code as follows:
 {{{
 def f(a,i)

   if i<3
 return 2
   else
 v1=f(a,i-1)
 v2=f(a,i-2)
 v=v1*v2+a
 if v==0
   printf "v1=%d,v2=%d,v=%d i=%d\n" ,v1,v2,v,i
 end
 return v
   end
  return 1
 end
 s=Time.now
 n=11
 v=f(0,n)
 t=Time.now-s

 printf "f(%d,%d)=%d,comsume time%10.5f seconds\n" ,0,n,v,t

 s=Time.now
 n=11
 v=f(1,n)
 t=Time.now-s

 printf "f(%d,%d)=%d,comsume time%10.5f seconds\n" ,1,n,v,t
 }}}

 running it on ruby 1.8 & macruby 0.6,display:

 {{{
 $ macruby f.rb
 v1=36028797018963968,v2=17179869184,v=0 i=11
 f(0,11)=0,comsume time  0.014954 seconds
 f(1,11)=11568694537326272321321120595206,comsume time  0.35 seconds
 $ ruby f.rb
 f(0,11)=618970019642690137449562112,comsume time   0.00022 seconds
 f(1,11)=11568694537326272321321120595206,comsume time   0.00019 seconds

 }}}

-- 
Ticket URL: 
MacRuby 

___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel