Clone
Gustaf Neumann <neumann@wu-wien.ac.at>
committed
on 01 Feb 16
- improve robustness of serializer, otherwise "::nx::Object::slot::__info" triggers an exception
2-1-0-rc + 44 more
tests/parameters.test (+4 -2)
1844 1844     ? [list [self] attribute [list y2:int b]] {expected integer but got "b"}
1845 1845
1846 1846     # set variable again, without -nocomplain
1847 1847     ? [list [self] variable x1:int 1] {Object ::enterprise has already an instance variable named 'x1'}
1848 1848     ? [list [self] attribute [list x2:int 2]] {Object ::enterprise has already an instance variable named 'x2'}
1849 1849
1850 1850     # set variable with a value checker, multiple
1851 1851     ? [list [self] variable  -nocomplain xm1:int,1..n {1 2 3}] ""
1852 1852     ? [list [self] attribute -nocomplain [list xm2:int,1..n {1 2 3}]] "::enterprise::xm2"
1853 1853
1854 1854     # in both cases, we expect instance variables
1855 1855     ? [list [self] eval {set :xm1}] "1 2 3"
1856 1856     ? [list [self] eval {set :xm2}] "1 2 3"
1857 1857
1858 1858     # set variable with a value checker, multiple with invalid value
1859 1859     ? [list [self] variable  -nocomplain xm1:int,1..n {1 2a 3}] \
1860 1860         {invalid value in "1 2a 3": expected integer but got "2a"}
1861 1861     ? [list [self] attribute -nocomplain [list xm2:int,1..n {1 2a 3}]] \
1862 1862         {invalid value in "1 2a 3": expected integer but got "2a"}
1863 1863
1864       # more tests, e.g. multiplicity and user-defined type
1865       # incremental,
  1864     # useless definition
  1865     ? [list [self] variable dummy:int] {Variable definition for 'dummy' (without default and accessor) is useless}
  1866
  1867     # more tests, e.g. user-defined type and incremental
1866 1868   }
1867 1869
1868 1870   nx::Class create C {
1869 1871     # set 2 variables, one via variable, one via attribute
1870 1872     ? [list [self] class variable -nocomplain v "v0"] ""
1871 1873     ? [list [self] class attribute -nocomplain [list a "a0"]] "::C::a"
1872 1874
1873 1875     # in both cases, we expect instance variables
1874 1876     ? [list [self] eval {set :v}] "v0"
1875 1877     ? [list [self] eval {set :a}] "a0"
1876 1878
1877 1879     # check variable with value constraint
1878 1880     ? [list [self] class variable -nocomplain x:int "0"] ""
1879 1881     ? [list [self] class variable -nocomplain y:int "a0"] {expected integer but got "a0"}
1880 1882   }
1881 1883
1882 1884 }