cppyabm
1.0.17
An agent-based library to integrate C++ and Python
examples
Cppy
build
_deps
pybind11-src
tests
test_tagbased_polymorphic.py
Go to the documentation of this file.
1
# -*- coding: utf-8 -*-
2
from
pybind11_tests
import
tagbased_polymorphic
as
m
3
4
5
def
test_downcast
():
6
zoo = m.create_zoo()
7
assert
[
type
(animal)
for
animal
in
zoo] == [
8
m.Labrador,
9
m.Dog,
10
m.Chihuahua,
11
m.Cat,
12
m.Panther,
13
]
14
assert
[animal.name
for
animal
in
zoo] == [
15
"Fido"
,
16
"Ginger"
,
17
"Hertzl"
,
18
"Tiger"
,
19
"Leo"
,
20
]
21
zoo[1].sound =
"woooooo"
22
assert
[dog.bark()
for
dog
in
zoo[:3]] == [
23
"Labrador Fido goes WOOF!"
,
24
"Dog Ginger goes woooooo"
,
25
"Chihuahua Hertzl goes iyiyiyiyiyi and runs in circles"
,
26
]
27
assert
[cat.purr()
for
cat
in
zoo[3:]] == [
"mrowr"
,
"mrrrRRRRRR"
]
28
zoo[0].excitement -= 1000
29
assert
zoo[0].excitement == 14000
type
Definition:
pytypes.h:915
test_tagbased_polymorphic.test_downcast
def test_downcast()
Definition:
test_tagbased_polymorphic.py:5
Generated by
1.8.19