ReturnableType working
This commit is contained in:
parent
62b07a3c2b
commit
321e45b75c
2 changed files with 9 additions and 7 deletions
|
|
@ -108,6 +108,9 @@ class BuiltInFunction(Function, BuiltInFunctionType):
|
||||||
return type(arg)
|
return type(arg)
|
||||||
|
|
||||||
def output_type(self) -> Type[Resolvable]:
|
def output_type(self) -> Type[Resolvable]:
|
||||||
|
if self.function_spec.return_type is ReturnableArgument:
|
||||||
|
generic_arg_index = self.function_spec.args.index(ReturnableArgument)
|
||||||
|
return self._arg_output_type(self.args[generic_arg_index])
|
||||||
if is_union(self.function_spec.return_type):
|
if is_union(self.function_spec.return_type):
|
||||||
union_types_list = []
|
union_types_list = []
|
||||||
for union_type in self.function_spec.return_type.__args__:
|
for union_type in self.function_spec.return_type.__args__:
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from unit.script.conftest import single_variable_output
|
||||||
|
|
||||||
from ytdl_sub.script.script import Script
|
from ytdl_sub.script.script import Script
|
||||||
from ytdl_sub.script.utils.exceptions import UserThrownRuntimeError
|
from ytdl_sub.script.utils.exceptions import UserThrownRuntimeError
|
||||||
|
|
@ -16,11 +17,9 @@ class TestErrorFunctions:
|
||||||
Script({"throw_error": "{%assert(False, 'test this error message')}"}).resolve()
|
Script({"throw_error": "{%assert(False, 'test this error message')}"}).resolve()
|
||||||
|
|
||||||
def test_user_assert_passthrough(self):
|
def test_user_assert_passthrough(self):
|
||||||
output = (
|
output = single_variable_output("{%assert(['a'], 'test this error message')}")
|
||||||
Script({"output": "{%assert(['a'], 'test this error message')}"})
|
|
||||||
.resolve(update=True)
|
|
||||||
.get("output")
|
|
||||||
.native
|
|
||||||
)
|
|
||||||
|
|
||||||
assert output == ["a"]
|
assert output == ["a"]
|
||||||
|
|
||||||
|
def test_user_assert_passthrough_as_arg(self):
|
||||||
|
output = single_variable_output("{%int(%assert('123', 'test this error message'))}")
|
||||||
|
assert output == 123
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue