Skip to content

Instantly share code, notes, and snippets.

View Watson1978's full-sized avatar

Shizuo Fujita Watson1978

View GitHub Profile
$:.unshift("/Library/RubyMotion/lib")
task :default => [:check_syntax, :simulator]
require 'motion/project'
Motion::Project::App.setup do |app|
# Use `rake config' to see complete project settings.
app.name = 'test'
end
desc "Checks the syntax"
describe "Application 'StopWatch'" do
before do
@app = UIApplication.sharedApplication
@controller = @app.windows.first.rootViewController
end
it "has one window" do
@app.windows.size.should == 1
end
@Watson1978
Watson1978 / test_mult.rb
Created May 3, 2012 06:15
MacRuby : bug : multiply
a = 2147483648
b = 2147483647
p a * b #=> 4611686016279904256
p (-a) * b #=> -4611686016279904256
p a * (-b) #=> -4611686016279904256
p (-a) * (-b) #=> 4611686016279904256
@Watson1978
Watson1978 / test_undef.rb
Created May 2, 2012 03:19
MacRuby : bug : undef
42.instance_eval{ undef :!= }
p "abc" != 42
diff --git a/misc/xcode4-templates/Project Templates/Base/MacRuby Application.xctemplate/TemplateInfo.plist b/misc/xcode4-templates/Project Templates/Base/MacRuby Application.xctemplate/TemplateInfo.plist
old mode 100755
new mode 100644
index 07ce384..4059c59
--- a/misc/xcode4-templates/Project Templates/Base/MacRuby Application.xctemplate/TemplateInfo.plist
+++ b/misc/xcode4-templates/Project Templates/Base/MacRuby Application.xctemplate/TemplateInfo.plist
@@ -20,6 +20,8 @@
<string>required</string>
<key>ARCHS</key>
<string>x86_64</string>
@Watson1978
Watson1978 / test_encoding.rb
Created April 21, 2012 14:37
MacRuby : bug : encoding
Encoding.default_internal = nil
p Encoding.default_internal
@Watson1978
Watson1978 / test_regexp6.rb
Created April 21, 2012 12:02
MacRuby : bug : regexp
p /a/i.options
p Regexp::IGNORECASE
p /a/x.options
p Regexp::EXTENDED
p /a/m.options
p Regexp::MULTILINE
@Watson1978
Watson1978 / test_regexp5.rb
Created April 20, 2012 16:29
MacRuby : bug : regexp
p /\Aa{1}+\z/ =~ "a"
p /\Aa{1}+\z/ =~ "aa"
p /\Aa{1}+/ =~ "aa"
p /a{1}+\z/ =~ "aa"
@Watson1978
Watson1978 / gist:2422246
Created April 19, 2012 16:48
Benchmark
$ ./run.rb --rubies=/Library/Frameworks/MacRuby.framework/Versions/0.10/usr/bin/macruby,/Library/Frameworks/MacRuby.framework/Versions/0.12/usr/bin/macruby
Name MacRuby 0.10 MacRuby 0.12
------------------------------------------------------------
array:<< 0.618269 0.625864
array:new 2.101463 2.188291
array:[] 0.136178 0.120287
array:[]= 0.330371 0.341209
eval:lit 0.642777 0.683426
hash:new 4.408205 4.511935
hash:[] 0.564072 0.644095
@Watson1978
Watson1978 / test_regexp4.rb
Created April 19, 2012 13:53
MacRuby : bug : regexp

Expect

$ ruby19  -e 'Regexp.allocate.to_s'
-e:1:in `to_s': uninitialized Regexp (TypeError)
	from -e:1:in `<main>'

Result