mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-12-22 20:05:31 +00:00
Updated test.cul.
This commit is contained in:
parent
d79d4f2437
commit
24b3da5d0f
@ -111,6 +111,30 @@ test_object_factory = fn () {
|
|||||||
assert(calc.sub(1) == 10)
|
assert(calc.sub(1) == 10)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_class = fn () {
|
||||||
|
// TODO: support 'prototype' property
|
||||||
|
Car = {
|
||||||
|
new: fn(miles_per_run) {
|
||||||
|
mut total_miles = 0
|
||||||
|
|
||||||
|
{
|
||||||
|
run: fn (times) {
|
||||||
|
total_miles = total_miles + miles_per_run * times
|
||||||
|
},
|
||||||
|
total: fn () {
|
||||||
|
total_miles
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
car = Car.new(5)
|
||||||
|
car.run(1)
|
||||||
|
car.run(2)
|
||||||
|
|
||||||
|
assert(car.total() == 15)
|
||||||
|
}
|
||||||
|
|
||||||
test_sum = fn () {
|
test_sum = fn () {
|
||||||
mut i = 1
|
mut i = 1
|
||||||
mut ret = 0
|
mut ret = 0
|
||||||
@ -150,6 +174,7 @@ test_array()
|
|||||||
test_function()
|
test_function()
|
||||||
test_object()
|
test_object()
|
||||||
test_object_factory()
|
test_object_factory()
|
||||||
|
test_class()
|
||||||
test_sum()
|
test_sum()
|
||||||
test_fib()
|
test_fib()
|
||||||
test_interpolated_string()
|
test_interpolated_string()
|
||||||
|
Loading…
Reference in New Issue
Block a user