demo
blockallHST
associations:HST
comment:HST
params:HST
scope:HST
setup:HST
test:HST
baselangccallHST
associations:HST
scope:HST
setup:HST
test:HST
pyallHST
associations:HST
comment:HST
params:HST
scope:HST
setup:HST
test:HST
1 namespace demo;
2
3 class Person
4 assocs<py>:...
5 std assoc sys;
6 assocs<cc>:...
7 std usertest assoc iostream;
8 scope:...
9
10 field name : str #:...
11 The name of the person.
12 field height : float #:...
13 Height of person in meters.
14 field weight : float #:...
15 Weight of person in kilograms.
16
17 lifecycle params:...
18 var name -> name;
19 var height -> height;
20 var weight -> weight;
21 scope:...
22 setup<py>:...
23 test.person1Is(demo.Person('Bob', 1.87, 87.0))
24 setup<cc>:...
25 test.person1Is(new demo::Person("Bob", 1.87, 87.0));
26 test<py>:...
27 test.iseqstr('Bob', test.person1().name())
28 test<cc>:...
29 test.iseqstr("Bob", test.person1()->name());
30 end;
31
32 test field person1 : demo.Person;
33
34 const
35 method bodyMassIndex : real<64> #:...
36 Compute the BMI for this person.
37 scope<py>:...
38 height = self.height()
39 return self.weight() / (height * height)
40 scope<cc>:...
41 double height = self.height();
42 return self.weight() / (height * height);
43 test<py>:...
44 person = test.person1()
45 test.isapprox(
46 24.879179, person.bodyMassIndex())
47 test<cc>:...
48 const auto* person = test.person1();
49 test.isapprox(
50 24.879179, person->bodyMassIndex());
51 end;
52