Skip to content

Commit 2dacadc

Browse files
committed
tests were fixed
1 parent 49dfa74 commit 2dacadc

18 files changed

+477
-491
lines changed

jac/examples/reference/architypes.jac

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ can print_base_classes(cls: type) -> type {
33
return cls;
44
}
55

6-
class Animal {}
6+
obj Animal {}
77

88
obj Domesticated {}
99

1010
@print_base_classes
11-
node Pet :Animal, Domesticated: {}
11+
obj Pet :Animal, Domesticated: {}
1212

13-
walker Person :Animal: {}
13+
obj Person :Animal: {}
1414

15-
walker Feeder :Person: {}
15+
obj Feeder :Person: {}
1616

1717
@print_base_classes
18-
walker Zoologist :Feeder: {}
18+
obj Zoologist :Feeder: {}

jac/examples/reference/architypes.py

Lines changed: 66 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,90 @@
1-
from jaclang.plugin.feature import JacFeature as jac
1+
from __future__ import annotations
2+
from jaclang import *
23

34

45
def print_base_classes(cls: type) -> type:
5-
print(f"Base classes of {cls.__name__}: {[c.__name__ for c in cls.__bases__]}")
6+
print(
7+
f"Base classes of {cls.__name__}: {List([c.__name__ for c in cls.__bases__])}"
8+
)
69
return cls
710

811

9-
# Since the Animal class cannot be inherit from object, (cause the base class will be changed at run time)
10-
# we need a base class.
11-
#
12-
# reference: https://stackoverflow.com/a/9639512/10846399
13-
#
14-
class Base:
12+
class Animal(Obj):
1513
pass
1614

1715

18-
@jac.make_obj(on_entry=[], on_exit=[])
19-
class Animal(Base):
20-
pass
21-
22-
23-
@jac.make_obj(on_entry=[], on_exit=[])
24-
class Domesticated(jac.Obj):
16+
class Domesticated(Obj):
2517
pass
2618

2719

2820
@print_base_classes
29-
@jac.make_node(on_entry=[], on_exit=[])
30-
class Pet(Animal, Domesticated, jac.Node):
21+
class Pet(Animal, Domesticated, Obj):
3122
pass
3223

3324

34-
@jac.make_walker(on_entry=[], on_exit=[])
35-
class Person(Animal, jac.Walker):
25+
class Person(Animal, Obj):
3626
pass
3727

3828

39-
@jac.make_walker(on_entry=[], on_exit=[])
40-
class Feeder(Person, jac.Walker):
29+
class Feeder(Person, Obj):
4130
pass
4231

4332

4433
@print_base_classes
45-
@jac.make_walker(on_entry=[], on_exit=[])
46-
class Zoologist(Feeder, jac.Walker):
34+
class Zoologist(Feeder, Obj):
4735
pass
36+
37+
38+
#
39+
#
40+
# (thakee): I guess I can remove the bellow code.
41+
#
42+
#
43+
44+
# from jaclang.plugin.feature import JacFeature as jac
45+
46+
47+
# def print_base_classes(cls: type) -> type:
48+
# print(f"Base classes of {cls.__name__}: {[c.__name__ for c in cls.__bases__]}")
49+
# return cls
50+
51+
52+
# # Since the Animal class cannot be inherit from object, (cause the base class will be changed at run time)
53+
# # we need a base class.
54+
# #
55+
# # reference: https://stackoverflow.com/a/9639512/10846399
56+
# #
57+
# class Base:
58+
# pass
59+
60+
61+
# @jac.make_obj(on_entry=[], on_exit=[])
62+
# class Animal(Base):
63+
# pass
64+
65+
66+
# @jac.make_obj(on_entry=[], on_exit=[])
67+
# class Domesticated(jac.Obj):
68+
# pass
69+
70+
71+
# @print_base_classes
72+
# @jac.make_node(on_entry=[], on_exit=[])
73+
# class Pet(Animal, Domesticated, jac.Node):
74+
# pass
75+
76+
77+
# @jac.make_walker(on_entry=[], on_exit=[])
78+
# class Person(Animal, jac.Walker):
79+
# pass
80+
81+
82+
# @jac.make_walker(on_entry=[], on_exit=[])
83+
# class Feeder(Person, jac.Walker):
84+
# pass
85+
86+
87+
# @print_base_classes
88+
# @jac.make_walker(on_entry=[], on_exit=[])
89+
# class Zoologist(Feeder, jac.Walker):
90+
# pass

jac/examples/reference/builtin_types.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
from jaclang import List
2+
13
a = 9.2
24
b = 44
3-
c = [2, 4, 6, 10]
5+
c = List([2, 4, 6, 10]) # (thakee):
46
d = {"name": "john", "age": 28}
57
e = ("jaseci", 5, 4, 14)
68
f = True
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
from __future__ import annotations
2-
from jaclang.plugin.feature import JacFeature as _Jac
2+
from jaclang.plugin.feature import JacFeature as Jac
33

44
a = 5
55
b = 2
66

77

8-
@_Jac.create_test
8+
@Jac.create_test
99
def test_test1(check) -> None:
1010
check.assertAlmostEqual(a, 6)
1111

1212

13-
@_Jac.create_test
13+
@Jac.create_test
1414
def test_test2(check) -> None:
1515
check.assertTrue(a != b)
1616

1717

18-
@_Jac.create_test
18+
@Jac.create_test
1919
def test_test3(check) -> None:
2020
check.assertIn("d", "abc")
2121

2222

23-
@_Jac.create_test
23+
@Jac.create_test
2424
def test_test4(check) -> None:
2525
check.assertEqual(a - b, 3)
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from __future__ import annotations
2-
from jaclang.plugin.feature import JacFeature as _Jac
2+
from jaclang.plugin.feature import JacFeature as Jac
33

44

55
# Since the Animal class cannot be inherit from object, (cause the base class will be changed at run time)
@@ -11,13 +11,13 @@ class Base:
1111
pass
1212

1313

14-
@_Jac.make_walker(on_entry=[_Jac.DSFunc("self_destruct", None)], on_exit=[])
14+
@Jac.make_walker(on_entry=[Jac.DSFunc("self_destruct", None)], on_exit=[])
1515
class Visitor(Base):
1616
def self_destruct(self, _jac_here_) -> None:
1717
print("get's here")
18-
_Jac.disengage(self)
18+
Jac.disengage(self)
1919
return
2020
print("but not here")
2121

2222

23-
_Jac.spawn_call(_Jac.get_root(), Visitor())
23+
Jac.spawn_call(Jac.get_root(), Visitor())
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from __future__ import annotations
2-
from jaclang.plugin.feature import JacFeature as _Jac
2+
from jaclang.plugin.feature import JacFeature as Jac
33

44

55
# Since the Animal class cannot be inherit from object, (cause the base class will be changed at run time)
@@ -11,27 +11,27 @@ class Base:
1111
pass
1212

1313

14-
@_Jac.make_walker(on_entry=[_Jac.DSFunc("travel", _Jac.get_root_type())], on_exit=[])
14+
@Jac.make_walker(on_entry=[Jac.DSFunc("travel", Jac.get_root_type())], on_exit=[])
1515
class Visitor(Base):
16-
def travel(self, _jac_here_: _Jac.get_root_type()) -> None:
17-
if _Jac.visit_node(
18-
self, _Jac.edge_ref(_jac_here_, None, _Jac.EdgeDir.OUT, None, None)
16+
def travel(self, _jac_here_: Jac.get_root_type()) -> None:
17+
if Jac.visit_node(
18+
self, Jac.edge_ref(_jac_here_, None, Jac.EdgeDir.OUT, None, None)
1919
):
2020
pass
21-
elif _Jac.visit_node(self, _Jac.get_root()):
21+
elif Jac.visit_node(self, Jac.get_root()):
2222
pass
2323

2424

25-
@_Jac.make_node(on_entry=[_Jac.DSFunc("speak", Visitor)], on_exit=[])
25+
@Jac.make_node(on_entry=[Jac.DSFunc("speak", Visitor)], on_exit=[])
2626
class item(Base):
2727
def speak(self, _jac_here_: Visitor) -> None:
2828
print("Hey There!!!")
29-
_Jac.disengage(_jac_here_)
29+
Jac.disengage(_jac_here_)
3030
return
3131

3232

3333
i = 0
3434
while i < 5:
35-
_Jac.connect(_Jac.get_root(), item(), _Jac.build_edge(_Jac.EdgeDir.OUT, None, None))
35+
Jac.connect(Jac.get_root(), item(), Jac.build_edge(Jac.EdgeDir.OUT, None, None))
3636
i += 1
37-
_Jac.spawn_call(_Jac.get_root(), Visitor())
37+
Jac.spawn_call(Jac.get_root(), Visitor())
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from __future__ import annotations
2-
from jaclang.plugin.feature import JacFeature as _Jac
2+
from jaclang.plugin.feature import JacFeature as Jac
33

44

55
# Since the Animal class cannot be inherit from object, (cause the base class will be changed at run time)
@@ -11,25 +11,25 @@ class Base:
1111
pass
1212

1313

14-
@_Jac.make_walker(on_entry=[_Jac.DSFunc("travel", _Jac.get_root_type())], on_exit=[])
14+
@Jac.make_walker(on_entry=[Jac.DSFunc("travel", Jac.get_root_type())], on_exit=[])
1515
class Visitor(Base):
16-
def travel(self, _jac_here_: _Jac.get_root_type()) -> None:
17-
if _Jac.visit_node(
18-
self, _Jac.edge_ref(_jac_here_, None, _Jac.EdgeDir.OUT, None, None)
16+
def travel(self, _jac_here_: Jac.get_root_type()) -> None:
17+
if Jac.visit_node(
18+
self, Jac.edge_ref(_jac_here_, None, Jac.EdgeDir.OUT, None, None)
1919
):
2020
pass
21-
elif _Jac.visit_node(self, _Jac.get_root()):
21+
elif Jac.visit_node(self, Jac.get_root()):
2222
pass
2323

2424

25-
@_Jac.make_node(on_entry=[_Jac.DSFunc("speak", Visitor)], on_exit=[])
25+
@Jac.make_node(on_entry=[Jac.DSFunc("speak", Visitor)], on_exit=[])
2626
class item(Base):
2727
def speak(self, _jac_here_: Visitor) -> None:
2828
print("Hey There!!!")
2929

3030

3131
i = 0
3232
while i < 5:
33-
_Jac.connect(_Jac.get_root(), item(), _Jac.build_edge(_Jac.EdgeDir.OUT, None, None))
33+
Jac.connect(Jac.get_root(), item(), Jac.build_edge(Jac.EdgeDir.OUT, None, None))
3434
i += 1
35-
_Jac.spawn_call(_Jac.get_root(), Visitor())
35+
Jac.spawn_call(Jac.get_root(), Visitor())

0 commit comments

Comments
 (0)