PageRenderTime 11ms CodeModel.GetById 1ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/ruby/virtual_poly_runme.rb

#
Ruby | 33 lines | 12 code | 7 blank | 14 comment | 8 complexity | b185d1d196966ca36d05245899e545f3 MD5 | raw file
 1#!/usr/bin/env ruby
 2#
 3# Put description here
 4#
 5# 
 6# 
 7# 
 8#
 9
10require 'swig_assert'
11
12require 'virtual_poly'
13
14d = Virtual_poly::NDouble.new(3.5)
15i = Virtual_poly::NInt.new(2)
16
17#
18# polymorphic return type working
19#
20dc = d.copy
21ic = i.copy
22
23raise RuntimeError if d.get != dc.get
24raise RuntimeError if i.get != ic.get
25
26#
27# 'narrowing' working ('nnumber' returns a NNumber)
28#
29ddc = Virtual_poly::NDouble.narrow(dc.nnumber)
30raise RuntimeError if d.get != ddc.get 
31
32dic = Virtual_poly::NInt.narrow(ic.nnumber)
33raise RuntimeError if i.get != dic.get