File: director_classic_runme.php

package info (click to toggle)
renderdoc 1.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 79,584 kB
  • sloc: cpp: 491,671; ansic: 285,823; python: 12,617; java: 11,345; cs: 7,181; makefile: 6,703; yacc: 5,682; ruby: 4,648; perl: 3,461; php: 2,119; sh: 2,068; lisp: 1,835; tcl: 1,068; ml: 747; xml: 137
file content (150 lines) | stat: -rw-r--r-- 3,531 bytes parent folder | download | duplicates (16)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php

require "tests.php";
require "director_classic.php";

// No new functions
check::functions(array(being_id,person_id,child_id,grandchild_id,caller_delcallback,caller_setcallback,caller_resetcallback,caller_call,caller_baseclass));
// No new classes
check::classes(array(Being,Person,Child,GrandChild,OrphanPerson,OrphanChild,Caller));
// now new vars
check::globals(array());

class TargetLangPerson extends Person {
  function id() {
    $identifier = "TargetLangPerson";
    return $identifier;
  }
}

class TargetLangChild extends Child {
  function id() {
    $identifier = "TargetLangChild";
    return $identifier;
  }
}

class TargetLangGrandChild extends GrandChild {
  function id() {
    $identifier = "TargetLangGrandChild";
    return $identifier;
  }
}

# Semis - don't override id() in target language
class TargetLangSemiPerson extends Person {
  # No id() override
}

class TargetLangSemiChild extends Child {
  # No id() override
}

class TargetLangSemiGrandChild extends GrandChild {
  # No id() override
}

# Orphans - don't override id() in C++
class TargetLangOrphanPerson extends OrphanPerson {
  function id() {
    $identifier = "TargetLangOrphanPerson";
    return $identifier;
  }
}

class TargetLangOrphanChild extends OrphanChild {
  function id() {
    $identifier = "TargetLangOrphanChild";
    return $identifier;
  }
}

function mycheck($person, $expected) {
  $debug = 0;
  # Normal target language polymorphic call
  $ret = $person->id();
  if ($debug)
    print $ret . "\n";
  check::equal($ret, $expected, "#1 failed");

  # Polymorphic call from C++
  $caller = new Caller();
  $caller->setCallback($person);
  $ret = $caller->call();
  if ($debug)
    print $ret . "\n";
  check::equal($ret, $expected, "#2 failed");

  # Polymorphic call of object created in target language and passed to 
  # C++ and back again
  $baseclass = $caller->baseClass();
  $ret = $baseclass->id();
  if ($debug)
    print $ret . "\n";
  # TODO: Currently we do not track the dynamic type of returned 
  # objects, so in case it's possible that the dynamic type is not equal 
  # to the static type, we skip this check.
  if (get_parent_class($person) === false)
    check::equal($ret, $expected, "#3 failed");

  $caller->resetCallback();
  if ($debug)
    print "----------------------------------------\n";
}

$person = new Person();
mycheck($person, "Person");
unset($person);

$person = new Child();
mycheck($person, "Child");
unset($person);

$person = new GrandChild();
mycheck($person, "GrandChild");
unset($person);

$person = new TargetLangPerson();
mycheck($person, "TargetLangPerson");
unset($person);

$person = new TargetLangChild();
mycheck($person, "TargetLangChild");
unset($person);

$person = new TargetLangGrandChild();
mycheck($person, "TargetLangGrandChild");
unset($person);

# Semis - don't override id() in target language
$person = new TargetLangSemiPerson();
mycheck($person, "Person");
unset($person);

$person = new TargetLangSemiChild();
mycheck($person, "Child");
unset($person);

$person = new TargetLangSemiGrandChild();
mycheck($person, "GrandChild");
unset($person);

# Orphans - don't override id() in C++
$person = new OrphanPerson();
mycheck($person, "Person");
unset($person);

$person = new OrphanChild();
mycheck($person, "Child");
unset($person);

$person = new TargetLangOrphanPerson();
mycheck($person, "TargetLangOrphanPerson");
unset($person);

$person = new TargetLangOrphanChild();
mycheck($person, "TargetLangOrphanChild");
unset($person);

check::done();
?>