summaryrefslogtreecommitdiffstats
path: root/qtruby/rubylib/examples/testcases
diff options
context:
space:
mode:
Diffstat (limited to 'qtruby/rubylib/examples/testcases')
-rw-r--r--qtruby/rubylib/examples/testcases/bugs.rb57
-rw-r--r--qtruby/rubylib/examples/testcases/error_reporting.rb85
-rw-r--r--qtruby/rubylib/examples/testcases/opoverloading.rb46
3 files changed, 188 insertions, 0 deletions
diff --git a/qtruby/rubylib/examples/testcases/bugs.rb b/qtruby/rubylib/examples/testcases/bugs.rb
new file mode 100644
index 00000000..6b5e3153
--- /dev/null
+++ b/qtruby/rubylib/examples/testcases/bugs.rb
@@ -0,0 +1,57 @@
+require 'Qt'
+
+
+#### TODO ###
+# dup of qobject crash
+def bug1
+ p1 = Qt::Point.new(5,5)
+ p1.setX 5
+ p p1
+ p3 = p1.dup
+ p3.setX 5
+ p p3
+end
+#bug1
+
+
+#### FIXED ###
+def bug3
+ a = Qt::Application.new(ARGV)
+ @file = Qt::PopupMenu.new
+ @file.insertSeparator
+ Qt::debug_level = Qt::DebugLevel::High
+ p $qApp
+ @file.insertItem("Quit", $qApp, SLOT('quit()'))
+ @file.exec
+end
+#bug3
+
+
+class CPUWaster < Qt::Widget
+ def initialize(*k)
+ super(*k)
+ end
+ def draw
+ painter = Qt::Painter.new(self)
+ 0.upto(1000) { |i|
+ cw, ch = width, height
+ c = Qt::Color.new(rand(255), rand(255), rand(255))
+ x = rand(cw - 8)
+ y = rand(cw - 8)
+ w = rand(cw - x)
+ h = rand(cw - y)
+ brush = Qt::Brush.new(c)
+ brush.setStyle(Qt::Dense6Pattern)
+ Qt::debug_level = Qt::DebugLevel::High
+ painter.fillRect(Qt::Rect.new(x, y, w, h), brush)
+ Qt::debug_level = Qt::DebugLevel::Off
+ }
+ end
+end
+def bug4
+ Qt::Application.new(ARGV)
+ w = CPUWaster.new
+ w.show
+ w.draw
+end
+bug4
diff --git a/qtruby/rubylib/examples/testcases/error_reporting.rb b/qtruby/rubylib/examples/testcases/error_reporting.rb
new file mode 100644
index 00000000..e2012447
--- /dev/null
+++ b/qtruby/rubylib/examples/testcases/error_reporting.rb
@@ -0,0 +1,85 @@
+require 'Qt'
+
+#### CRASH ###
+# param mismatch?
+class Bug1 < Qt::PushButton
+ def initialize(*k)
+ super(*k)
+ end
+ def Bug1.test
+ a = Qt::Application.new(ARGV)
+ w = Qt::VBox.new
+ hello = Bug1.new(a)
+ hello.resize(100, 30)
+ a.setMainWidget(w)
+ hello.show()
+ a.exec()
+ end
+end
+#Bug1.test
+
+
+#### MORE DEBUG INFO NEEDED ###
+# missing method
+class Bug2 < Qt::VBox
+ def initialize(*k)
+ super(*k)
+ end
+ def Bug2.test
+ a = Qt::Application.new(ARGV)
+ w = Bug2.new
+ a.setMainWidget(w)
+ w.show2()
+ a.exec()
+ end
+end
+#Bug2.test
+
+
+#### MORE DEBUG INFO NEEDED ###
+# missing prototype
+class Bug2a < Qt::VBox
+ def initialize(*k)
+ super(*k)
+ end
+ def Bug2a.test
+ a = Qt::Application.new(ARGV)
+ w = Bug2a.new
+ a.setMainWidget(w)
+ w.show(p)
+ a.exec()
+ end
+end
+Bug2a.test
+
+
+#### FIXED ###
+# no such constructor for PushButton
+class Bug3 < Qt::PushButton
+ def initialize
+ super
+ end
+ def Bug3.test
+ a = Qt::Application.new(ARGV)
+ hello = Bug3.new
+ hello.resize(100, 30)
+ a.setMainWidget(hello)
+ hello.show()
+ a.exec()
+ end
+end
+#Bug3.test
+
+
+#### FIXED ###
+# no *class* variable/method resize in PushButton
+class Bug4 < Qt::PushButton
+ def initialize
+ super
+ end
+ def Bug4.test
+ hello = Bug4
+ hello.resize(100, 30)
+ end
+end
+#Bug4.test
diff --git a/qtruby/rubylib/examples/testcases/opoverloading.rb b/qtruby/rubylib/examples/testcases/opoverloading.rb
new file mode 100644
index 00000000..1798a995
--- /dev/null
+++ b/qtruby/rubylib/examples/testcases/opoverloading.rb
@@ -0,0 +1,46 @@
+require 'Qt'
+
+class Qt::Point
+ def to_s
+ "(#{x}, #{y})"
+ end
+end
+
+$t = binding
+def test(str)
+ puts "#{str.ljust 25} => #{eval(str, $t)}"
+end
+
+test("p1 = Qt::Point.new(5,5)")
+test("p2 = Qt::Point.new(20,20)")
+test("p1 + p2")
+test("p1 - p2")
+test("-p1 + p2")
+test("p2 += p1")
+test("p2 -= p1")
+test("p2 * 3")
+
+class Qt::Region
+ def to_s
+ "(#{isNull})"
+ end
+end
+
+test("r1 = Qt::Region.new()")
+test("r2 = Qt::Region.new( 100,100,200,80, Qt::Region::Ellipse )")
+test("r1 + r2")
+
+class Qt::WMatrix
+ def to_s
+ "(#{m11}, #{m12}, #{m21}, #{m22}, #{dx}, #{dy})"
+ end
+end
+
+test("a = Math::PI/180 * 25") # convert 25 to radians
+test("sina = Math.sin(a)")
+test("cosa = Math.cos(a)")
+test("m1 = Qt::WMatrix.new(1, 0, 0, 1, 10, -20)") # translation matrix
+test("m2 = Qt::WMatrix.new( cosa, sina, -sina, cosa, 0, 0 )")
+test("m3 = Qt::WMatrix.new(1.2, 0, 0, 0.7, 0, 0)") # scaling matrix
+test("m = Qt::WMatrix.new")
+test("m = m3 * m2 * m1") # combine all transformations