Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
wrap
pybind11
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, m.Dog, m.Chihuahua, m.Cat, m.Panther
9
]
10
assert
[animal.name
for
animal
in
zoo] == [
11
"Fido"
,
"Ginger"
,
"Hertzl"
,
"Tiger"
,
"Leo"
12
]
13
zoo[1].sound =
"woooooo"
14
assert
[dog.bark()
for
dog
in
zoo[:3]] == [
15
"Labrador Fido goes WOOF!"
,
16
"Dog Ginger goes woooooo"
,
17
"Chihuahua Hertzl goes iyiyiyiyiyi and runs in circles"
18
]
19
assert
[cat.purr()
for
cat
in
zoo[3:]] == [
"mrowr"
,
"mrrrRRRRRR"
]
20
zoo[0].excitement -= 1000
21
assert
zoo[0].excitement == 14000
test_tagbased_polymorphic.test_downcast
def test_downcast()
Definition:
test_tagbased_polymorphic.py:5
type
Definition:
pytypes.h:897
gtsam
Author(s):
autogenerated on Sat May 8 2021 02:46:04