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