1 namespace demo;
2
3 class Person scope:...
4
5 field name : str #:...
6 The name of the person.
7 field height : double #:...
8 Height of person in meters.
9 field weight : double #:...
10 Weight of person in kilograms.
11
12 lifecycle params:...
13 var name -> name;
14 var height -> height;
15 var weight -> weight;
16 setup:...
17 test.personIs(
18 demo.Person('Bob', 1.87, 86.3))
19 test:...
20 test.iseq('Bob', test.person().name())
21
22 test field person : demo.Person;
23
24 method bodyMassIndex : double #:...
25 Compute the BMI for this person.
26 scope:...
27 height = self.height()
28 return self.weight() / (height * height)
29 test:...
30 person = test.person()
31 test.isapprox(
32 24.67900, person.bodyMassIndex())
33