Add property accessors to methodmaps.

This commit is contained in:
David Anderson
2014-06-22 22:02:02 -07:00
parent b6eb3b041b
commit a17ad1c5a5
19 changed files with 556 additions and 285 deletions
@@ -0,0 +1,9 @@
methodmap Crab {
property int Crab {
public native get();
public native get();
}
}
public main() {
}
@@ -0,0 +1 @@
getter for Crab already exists
@@ -1,7 +1,7 @@
native X:Crab();
native X:Crab(X:x);
methodmap X {
public X() = Crab;
public X() = Crab;
public X2() = Crab;
public X2() = Crab;
}
public main() {
@@ -1 +1 @@
X was already defined on this methodmap
X2 was already defined on this methodmap
@@ -0,0 +1,7 @@
methodmap Crab {
property int Crab;
property int Crab;
}
public main() {
}
@@ -0,0 +1 @@
Crab was already defined on this methodmap
@@ -1,3 +1,3 @@
type "Float" should be "float" in new-style declarations
type "String" should be "char" in new-style declarations
methodmap and class signatures must use new-style declarations
methodmap and class signatures must use new-style type declarations
@@ -0,0 +1,12 @@
native GetCrab(Crab:crab);
methodmap Crab {
property float Blah {
public get() = GetCrab;
}
}
public main() {
new Crab:crab = Crab:5;
new x = crab.Blah;
}
@@ -0,0 +1 @@
getter must have the same return type as property Crab (float)
@@ -0,0 +1 @@
(4) : warning 213: tag mismatch
@@ -0,0 +1,12 @@
native Float:GetCrab();
methodmap Crab {
property float Blah {
public get() = GetCrab();
}
}
public main() {
new Crab:crab = Crab:5;
new x = crab.Blah;
}
@@ -0,0 +1 @@
method must have a first argument compatible with the methodmap type (Crab)
@@ -0,0 +1,29 @@
native Float:GetCrabWhat(Crab:crab);
methodmap Crab {
public Crab(n) {
return Crab:n;
}
property Crab Yams {
public get() {
return Crab:5;
}
}
property int Blah {
public native get();
}
property float What {
public get() = GetCrabWhat;
}
}
print(n) {
return n
}
public main() {
new Crab:crab = Crab(10);
print(_:crab.Yams.Yams.Yams)
print(crab.Blah);
print(_:crab.What);
}
+9 -5
View File
@@ -39,6 +39,7 @@ def run_tests(args):
elif not compiled and kind != 'fail':
status = 'fail'
fails = []
if status == 'ok' and kind != 'pass':
lines = []
with open(os.path.join(testdir, test + '.txt')) as fp:
@@ -46,18 +47,21 @@ def run_tests(args):
lines.append(line.strip())
for line in lines:
if line not in stdout:
sys.stderr.write('Expected to find text in stdout: >>>\n')
sys.stderr.write(text)
sys.stderr.write('<<<\n')
status = 'fail'
fails += [
'Expected to find text in stdout: >>>\n',
line,
'<<<\n',
]
break
if status == 'fail':
if status == 'fail' or len(fails):
print('Test {0} ... FAIL'.format(test))
failed = True
sys.stderr.write('FAILED! Dumping stdout/stderr:\n')
sys.stderr.write(stdout)
sys.stderr.write(stderr)
for line in fails:
sys.stderr.write(line)
else:
print('Test {0} ... OK'.format(test))