mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-04-01 17:39:54 +08:00
[vm] Sync and add NEWS+tests for warning when overriding attr methods.
This commit is contained in:
3
NEWS
3
NEWS
@@ -1,5 +1,8 @@
|
||||
= RubyMotion 2.25 =
|
||||
|
||||
* Improved user feedback by printing a warning when overriding a protocol
|
||||
method that was previously defined with one of the `attr_*' methods. This
|
||||
may print false positives.
|
||||
* Fixed a bug which `rake device debug=1' does not work with Xcode 5.1.
|
||||
* Fixed an error in `rake device debug=1' if it would use UTF-8 as app name.
|
||||
* Fixed a bug where an application could not be installed and launched on the
|
||||
|
||||
@@ -35,6 +35,15 @@ module Bacon
|
||||
alias_method :on_64bit_it, RUBY_ARCH =~ /64/ ? :it : :xit
|
||||
|
||||
alias_method :on_ios_it, defined?(UIView) ? :it : :xit
|
||||
|
||||
def capture_warning
|
||||
$last_rb_warn = nil
|
||||
ENV['RM_CAPTURE_WARNINGS'] = '1'
|
||||
yield
|
||||
$last_rb_warn
|
||||
ensure
|
||||
ENV.delete('RM_CAPTURE_WARNINGS')
|
||||
end
|
||||
end
|
||||
|
||||
# Overrides the SpecDoxzRtput to provide colored output by default
|
||||
|
||||
@@ -28,3 +28,32 @@ describe "conformsToProtocol:" do
|
||||
TestObjCSubclassConformsToProtocolObject.new.conformsToProtocol(NSProtocolFromString('TestConformsToProtocol')).should == true
|
||||
end
|
||||
end
|
||||
|
||||
describe "A protocol method" do
|
||||
it "warns when overriding a method defined with the `attr_reader' macro" do
|
||||
class TestConformsToProtocolObject4
|
||||
attr_reader :requiredMethod1
|
||||
end
|
||||
|
||||
warning = capture_warning do
|
||||
class TestConformsToProtocolObject4
|
||||
def requiredMethod1; 42; end
|
||||
end
|
||||
end
|
||||
warning.should.match /protocol method `TestConformsToProtocolObject4#requiredMethod1'/
|
||||
end
|
||||
|
||||
xit "warns when overriding a method defined with the `attr_writer' macro" do
|
||||
class TestConformsToProtocolObject5
|
||||
attr_reader :requiredMethod1
|
||||
end
|
||||
|
||||
warning = capture_warning do
|
||||
class TestConformsToProtocolObject5
|
||||
#def requiredMethod1=(x); x; end
|
||||
def setRequiredMethod1(x); x; end
|
||||
end
|
||||
end
|
||||
warning.should.match /protocol method `TestConformsToProtocolObject5#requiredMethod1='/
|
||||
end
|
||||
end
|
||||
|
||||
2
vm
2
vm
Submodule vm updated: 995cead5b3...1e9b9c80c2
Reference in New Issue
Block a user