summaryrefslogtreecommitdiffstats
path: root/qtruby/rubylib/examples/testcases/opoverloading.rb
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit90825e2392b2d70e43c7a25b8a3752299a933894 (patch)
treee33aa27f02b74604afbfd0ea4f1cfca8833d882a /qtruby/rubylib/examples/testcases/opoverloading.rb
downloadtdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.tar.gz
tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'qtruby/rubylib/examples/testcases/opoverloading.rb')
-rw-r--r--qtruby/rubylib/examples/testcases/opoverloading.rb46
1 files changed, 46 insertions, 0 deletions
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