/trunk/Examples/test-suite/octave/virtual_poly_runme.m

# · MATLAB · 44 lines · 33 code · 11 blank · 0 comment · 6 complexity · de2229bbaa8492d2091fbbe6bd96e146 MD5 · raw file

  1. virtual_poly
  2. d = virtual_poly.NDouble(3.5);
  3. i = virtual_poly.NInt(2);
  4. #
  5. # the copy methods return the right polymorphic types
  6. #
  7. dc = d.copy();
  8. ic = i.copy();
  9. if (d.get() != dc.get())
  10. error
  11. endif
  12. if (i.get() != ic.get())
  13. error
  14. endif
  15. virtual_poly.incr(ic);
  16. if ((i.get() + 1) != ic.get())
  17. error
  18. endif
  19. dr = d.ref_this();
  20. if (d.get() != dr.get())
  21. error
  22. endif
  23. #
  24. # 'narrowing' also works
  25. #
  26. ddc = virtual_poly.NDouble_narrow(d.nnumber());
  27. if (d.get() != ddc.get())
  28. error
  29. endif
  30. dic = virtual_poly.NInt_narrow(i.nnumber());
  31. if (i.get() != dic.get())
  32. error
  33. endif