changed the superclass marker from '::' to ':'
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-10-03 22:54:03 +09:00
parent 0dbaa264f7
commit 6896da6870
5 changed files with 56 additions and 14 deletions

View File

@ -36,18 +36,18 @@ class super.a [ a ] { ##ERROR: syntax error - invalid class name 'super.a' for '
---
class a :: 20 { ##ERROR: syntax error - invalid superclass name '20' after '::' for 'class'
class a: 20 { ##ERROR: syntax error - invalid superclass name '20' after ':' for 'class'
}
---
class a :: class { ##ERROR: syntax error - invalid superclass name 'class' after '::' for 'class'
class a: class { ##ERROR: syntax error - invalid superclass name 'class' after ':' for 'class'
}
---
class a :: #(1 2) { ##ERROR: syntax error - no valid superclass name after '::' for 'class'
class a: #(1 2) { ##ERROR: syntax error - no valid superclass name after ':' for 'class'
}
---
@ -81,7 +81,7 @@ class B [ x y ] {
};
class X :: B [ a b ] {
class X: B [ a b ] {
fun(#ci) new(t) {
| a |
set self.a t;
@ -231,3 +231,16 @@ class a {
fun() { ##ERROR: syntax error - unnamed function defined with 'fun' prohibited in class initialziation context
}
}
---
class X10 [ x ] {
fun(#ci) make() { x := 1234; return self; };
fun get-x() { return x };
}
X11 := (class:X10 {
})
class X11 { ##ERROR: exception not handled - "prohibited redefintion of X11"
}

View File

@ -26,7 +26,7 @@ class A [ a b c ] {
fun get-c() { return self.c; };
};
class B :: A [ d e f ] {
class B: A [ d e f ] {
fun(#ci) newInstance(x y z) {
super:newInstance (* x 2) (* y 2) (* z 2);

View File

@ -31,11 +31,12 @@ else { printf "OK: t is %d\n" t };
j := #{ ((X:make):get-x): 9999, 4512: ((X: make): get-x) };
v := (dic.get j 1234);
if (nqv? v 9999) { printf "ERROR: v is not 9999\n" } \
else { printf "OK: value is %d\n" v };
else { printf "OK: value is %d\n" v };
v := (dic.get j 4512);
if (nqv? v 1234) { printf "ERROR: v is not 1234\n" } \
else { printf "OK: value is %d\n" v };
else { printf "OK: value is %d\n" v };
## --------------------------------------------------------------
@ -58,11 +59,11 @@ class X0 [ a b c d ] {
}; a := (X0:new); v := (a:x)
if (nqv? v 100) { printf "ERROR: v is not 100\n" } \
else { printf "OK: value is %d\n" v }
else { printf "OK: value is %d\n" v }
v := ((a:y) 20);
if (nqv? v 21) { printf "ERROR: v is not 21\n" } \
else { printf "OK: value is %d\n" v }
else { printf "OK: value is %d\n" v }
## --------------------------------------------------------------
@ -92,15 +93,15 @@ fun X1:get_a() {
v := ((X1:new):get_a)
if (nqv? v 20) { printf "ERROR: v is not 20 - %d\n" v } \
else { printf "OK: value is %d\n" v }
else { printf "OK: value is %d\n" v }
v := (((X1:new):make 5 6 7):get_j)
if (nqv? v 79) { printf "ERROR: v is not 79 - %d\n" v } \
else { printf "OK: value is %d\n" v }
else { printf "OK: value is %d\n" v }
v := (((X1:new):make 6 6 7):get_j)
if (nqv? v 70) { printf "ERROR: v is not 70 - %d\n" v } \
else { printf "OK: value is %d\n" v }
else { printf "OK: value is %d\n" v }
## --------------------------------------------------------------
@ -175,3 +176,17 @@ else { printf "OK: value is %d\n" v }
v := { X5:t; (X6:t) + 10 }
if (nqv? v 50) { printf "ERROR: v is not 50 - %d\n" v } \
else { printf "OK: value is %d\n" v }
## --------------------------------------------------------------
class X10 [ x ] {
fun(#ci) make() { x := 1234; return self; };
fun get-x() { return x };
}
X11 := (class:X10 {
})
v := (X11:make)
v := (v:get-x)
if (== v 1234) { printf "OK: v is %d\n" v } \
else {printf "ERROR: v is %d, not 1234\n" v }