-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
49dfa74
commit c75f955
Showing
20 changed files
with
568 additions
and
583 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,90 @@ | ||
from jaclang.plugin.feature import JacFeature as jac | ||
from __future__ import annotations | ||
from jaclang import * | ||
|
||
|
||
def print_base_classes(cls: type) -> type: | ||
print(f"Base classes of {cls.__name__}: {[c.__name__ for c in cls.__bases__]}") | ||
print( | ||
f"Base classes of {cls.__name__}: {List([c.__name__ for c in cls.__bases__])}" | ||
) | ||
return cls | ||
|
||
|
||
# Since the Animal class cannot be inherit from object, (cause the base class will be changed at run time) | ||
# we need a base class. | ||
# | ||
# reference: https://stackoverflow.com/a/9639512/10846399 | ||
# | ||
class Base: | ||
class Animal(Obj): | ||
pass | ||
|
||
|
||
@jac.make_obj(on_entry=[], on_exit=[]) | ||
class Animal(Base): | ||
pass | ||
|
||
|
||
@jac.make_obj(on_entry=[], on_exit=[]) | ||
class Domesticated(jac.Obj): | ||
class Domesticated(Obj): | ||
pass | ||
|
||
|
||
@print_base_classes | ||
@jac.make_node(on_entry=[], on_exit=[]) | ||
class Pet(Animal, Domesticated, jac.Node): | ||
class Pet(Animal, Domesticated, Obj): | ||
pass | ||
|
||
|
||
@jac.make_walker(on_entry=[], on_exit=[]) | ||
class Person(Animal, jac.Walker): | ||
class Person(Animal, Obj): | ||
pass | ||
|
||
|
||
@jac.make_walker(on_entry=[], on_exit=[]) | ||
class Feeder(Person, jac.Walker): | ||
class Feeder(Person, Obj): | ||
pass | ||
|
||
|
||
@print_base_classes | ||
@jac.make_walker(on_entry=[], on_exit=[]) | ||
class Zoologist(Feeder, jac.Walker): | ||
class Zoologist(Feeder, Obj): | ||
pass | ||
|
||
|
||
# | ||
# | ||
# (thakee): I guess I can remove the bellow code. | ||
# | ||
# | ||
|
||
# from jaclang.plugin.feature import JacFeature as jac | ||
|
||
|
||
# def print_base_classes(cls: type) -> type: | ||
# print(f"Base classes of {cls.__name__}: {[c.__name__ for c in cls.__bases__]}") | ||
# return cls | ||
|
||
|
||
# # Since the Animal class cannot be inherit from object, (cause the base class will be changed at run time) | ||
# # we need a base class. | ||
# # | ||
# # reference: https://stackoverflow.com/a/9639512/10846399 | ||
# # | ||
# class Base: | ||
# pass | ||
|
||
|
||
# @jac.make_obj(on_entry=[], on_exit=[]) | ||
# class Animal(Base): | ||
# pass | ||
|
||
|
||
# @jac.make_obj(on_entry=[], on_exit=[]) | ||
# class Domesticated(jac.Obj): | ||
# pass | ||
|
||
|
||
# @print_base_classes | ||
# @jac.make_node(on_entry=[], on_exit=[]) | ||
# class Pet(Animal, Domesticated, jac.Node): | ||
# pass | ||
|
||
|
||
# @jac.make_walker(on_entry=[], on_exit=[]) | ||
# class Person(Animal, jac.Walker): | ||
# pass | ||
|
||
|
||
# @jac.make_walker(on_entry=[], on_exit=[]) | ||
# class Feeder(Person, jac.Walker): | ||
# pass | ||
|
||
|
||
# @print_base_classes | ||
# @jac.make_walker(on_entry=[], on_exit=[]) | ||
# class Zoologist(Feeder, jac.Walker): | ||
# pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
from __future__ import annotations | ||
from jaclang.plugin.feature import JacFeature as _Jac | ||
from jaclang.plugin.feature import JacFeature as Jac | ||
|
||
a = 5 | ||
b = 2 | ||
|
||
|
||
@_Jac.create_test | ||
@Jac.create_test | ||
def test_test1(check) -> None: | ||
check.assertAlmostEqual(a, 6) | ||
|
||
|
||
@_Jac.create_test | ||
@Jac.create_test | ||
def test_test2(check) -> None: | ||
check.assertTrue(a != b) | ||
|
||
|
||
@_Jac.create_test | ||
@Jac.create_test | ||
def test_test3(check) -> None: | ||
check.assertIn("d", "abc") | ||
|
||
|
||
@_Jac.create_test | ||
@Jac.create_test | ||
def test_test4(check) -> None: | ||
check.assertEqual(a - b, 3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.