test/example-apps.rb in spqr-0.2.0 vs test/example-apps.rb in spqr-0.2.2
- old
+ new
@@ -121,6 +121,80 @@
qmf_class_name :QmfIntegerProp
qmf_package_name :example
end
+class QmfBoolProp
+ include ::SPQR::Manageable
+ SIZE = 7
+
+ def initialize(oid)
+ @int_id = oid
+ end
+
+ def spqr_object_id
+ @int_id
+ end
+
+ def QmfBoolProp.gen_objects(ct)
+ objs = []
+ ct.times do |x|
+ objs << (new(x))
+ end
+ objs
+ end
+
+ def QmfBoolProp.find_by_id(oid)
+ puts "calling QBP::find_by_id"
+ @qmf_bps ||= gen_objects(SIZE)
+ @qmf_bps[oid]
+ end
+
+ def QmfBoolProp.find_all
+ puts "calling QBP::find_all"
+ @qmf_bps ||= gen_objects(SIZE)
+ @qmf_bps
+ end
+
+ def is_id_even
+ @int_id % 2 == 0
+ end
+
+ qmf_property :int_id, :int, :index=>true
+ qmf_property :is_id_even, :bool
+
+ qmf_class_name :QmfBoolProp
+ qmf_package_name :example
+end
+
+class Failbot
+ include ::SPQR::Manageable
+
+ def Failbot.find_by_id(oid)
+ @failbots ||= [Failbot.new]
+ @failbots[0]
+ end
+
+ def Failbot.find_all
+ @failbots ||= [Failbot.new]
+ @failbots
+ end
+
+ def fail_with_no_result
+ fail 42, "This method should not succeed, with failure code 42"
+ end
+
+ expose :fail_with_no_result do |args|
+ end
+
+ def fail_without_expected_result
+ fail 17, "This method should not succeed, with failure code 17, and should return some garbage value"
+ end
+
+ expose :fail_without_expected_result do |args|
+ args.declare :result, :uint64, :out
+ end
+
+ qmf_package_name :example
+ qmf_class_name :Failbot
+end