mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-03-30 17:43:26 +08:00
add the tests which causes compile error
% rake spec
require 'motion/project' is deprecated, please require 'motion/project/template/ios' instead
Build ./build/iPhoneSimulator-7.0-Development
Build vendor/code
Compile ./spec/compile/compile1_spec.rb
Instruction does not dominate all uses!
%16 = call i32* @vm_block_dvar_slot(i8* %15, i32 0)
%27 = load i32* %16
This commit is contained in:
21
test/test/spec/compile/compile1_spec.rb
Normal file
21
test/test/spec/compile/compile1_spec.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
# BubbleWrap/motion/util/constants.rb
|
||||
module Constants
|
||||
module_function
|
||||
def get(base, values)
|
||||
case values
|
||||
when Array
|
||||
values.each { |i|
|
||||
get(base, i)
|
||||
}
|
||||
else
|
||||
Kernel.const_get("#{base}::#{values}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "compile1_spec" do
|
||||
it "should work" do
|
||||
values = ["EEXIST", "EINTR"]
|
||||
Constants.get("Errno", values).should == values
|
||||
end
|
||||
end
|
||||
18
test/test/spec/compile/compile2_spec.rb
Normal file
18
test/test/spec/compile/compile2_spec.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
# geomotion/lib/geomotion/cg_affine_transform.rb
|
||||
class CGAffineTransform
|
||||
def self.make(options)
|
||||
if options.key?(:a)
|
||||
args = [:a, :b].map do |key|
|
||||
options[key]
|
||||
end
|
||||
else
|
||||
options[:translate]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "compile2_spec" do
|
||||
it "should work" do
|
||||
CGAffineTransform.make({:a => 42, :b => 7}).should == [42, 7]
|
||||
end
|
||||
end
|
||||
41
test/test/spec/compile/compile3_spec.rb
Normal file
41
test/test/spec/compile/compile3_spec.rb
Normal file
@@ -0,0 +1,41 @@
|
||||
# motion-state-machine/spec/transition_spec.rb
|
||||
module StateMachine
|
||||
class Transition
|
||||
def initialize(options)
|
||||
@options = options.dup
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "compile3_spec" do
|
||||
before do
|
||||
@options = {
|
||||
state_machine: @state_machine,
|
||||
from: :awake,
|
||||
to: :tired,
|
||||
on: :work_done
|
||||
}
|
||||
@transition = StateMachine::Transition.new @options
|
||||
end
|
||||
|
||||
it "should work" do
|
||||
# :unless :if allowed?
|
||||
{
|
||||
[nil, nil] => true,
|
||||
[nil, false] => false,
|
||||
[nil, true] => true,
|
||||
[false, nil] => true,
|
||||
[false, false] => false,
|
||||
[false, true] => true,
|
||||
[true, nil] => false,
|
||||
[true, false] => false,
|
||||
[true, true] => false,
|
||||
}.each do |guards, result|
|
||||
transition = StateMachine::Transition.new @options.dup
|
||||
transition.options[:unless] = proc {guards[0]} unless guards[0].nil?
|
||||
transition.options[:if] = proc {guards[1]} unless guards[1].nil?
|
||||
end
|
||||
|
||||
1.should == 1
|
||||
end
|
||||
end
|
||||
26
test/test/spec/compile/compile4_spec.rb
Normal file
26
test/test/spec/compile/compile4_spec.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
# motion-stump/lib/stump/mock.rb
|
||||
class Object
|
||||
def mock!(options = {}, &block)
|
||||
|
||||
behavior = if block_given?
|
||||
lambda do |*args|
|
||||
|
||||
block.call(*args)
|
||||
end
|
||||
elsif options[:yield]
|
||||
lambda do |*args|
|
||||
yield(options[:yield])
|
||||
end
|
||||
else
|
||||
lambda do |*args|
|
||||
return options[:return]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "compile4_spec" do
|
||||
it "should work" do
|
||||
mock! { 42 }.call.should == 42
|
||||
end
|
||||
end
|
||||
35
test/test/spec/compile/compile5_spec.rb
Normal file
35
test/test/spec/compile/compile5_spec.rb
Normal file
@@ -0,0 +1,35 @@
|
||||
# motion-support/motion/callbacks.rb
|
||||
module MotionSupport
|
||||
module Callbacks
|
||||
class Callback #:nodoc:#
|
||||
def initialize(chain, filter, kind, options, klass)
|
||||
end
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
def __update_callbacks(name, filters = [])
|
||||
yield :a, :b, [:c, :d]
|
||||
end
|
||||
|
||||
def set_callback(name, *filter_list)
|
||||
mapped = nil
|
||||
|
||||
__update_callbacks(name, filter_list, block) do |target, chain, type, filters, options|
|
||||
mapped ||= filters.map do |filter|
|
||||
Callback.new(chain, filter, type, options.dup, self)
|
||||
end
|
||||
|
||||
options[:prepend] ? chain.prepend(*mapped) : chain.append(*mapped)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "compile5_spec" do
|
||||
it "should work" do
|
||||
1.should == 1
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user