repo_id stringclasses 409
values | prefix large_stringlengths 34 36.3k | target large_stringlengths 1 498 | assertion_type stringclasses 31
values | difficulty stringclasses 8
values | test_file stringlengths 10 121 | test_function stringlengths 1 104 | test_class stringlengths 0 51 | lineno int32 2 11.3k | commit_idx int32 |
|---|---|---|---|---|---|---|---|---|---|
spylang/spy | import pytest
from spy.tests.support import CompilerTest
class TestRange(CompilerTest):
def test_fastiter(self):
src = """
from _range import range, range_iterator
def get_iter() -> range_iterator:
r = range(3)
return r.__fastiter__()
def next(it: range_i... | 1 | assert | numeric_literal | spy/tests/stdlib/test__range.py | test_fastiter | TestRange | 46 | null |
spylang/spy | import pytest
from spy.fqn import FQN
from spy.tests.support import CompilerTest, no_C
from spy.vm.b import B
from spy.vm.modules.__spy__.interp_dict import W_InterpDictType
class TestInterpDict(CompilerTest):
def test_interp_repr(self):
mod = self.compile("""
from __spy__ import interp_dict
... | repr(w_d) | assert | func_call | spy/tests/compiler/__spy__/test_interp_dict.py | test_interp_repr | TestInterpDict | 110 | null |
spylang/spy | from spy.location import Loc
from spy.vm.b import B
from spy.vm.object import W_Object
from spy.vm.opspec import W_MetaArg
from spy.vm.vm import SPyVM
def test_oparg_key():
vm = SPyVM()
w_a = vm.wrap("x")
w_b = vm.wrap("x")
wam_a = W_MetaArg.from_w_obj(vm, w_a)
wam_b = W_MetaArg.from_w_obj(vm, w_b)... | wam_b.spy_key(vm) | assert | func_call | spy/tests/vm/test_opspec.py | test_oparg_key | 39 | null | |
spylang/spy | from spy.fqn import FQN, NSPart
def test_FQN_hash_eq():
a = FQN("aaa::bbb")
b = FQN("aaa::bbb")
assert a == | b | assert | variable | spy/tests/test_fqn.py | test_FQN_hash_eq | 37 | null | |
spylang/spy | from typing import Any
import pytest
from spy.errors import SPyError
from spy.fqn import FQN
from spy.tests.support import (
CompilerTest,
expect_errors,
no_C,
only_interp,
skip_backends,
)
from spy.vm.b import B
class TestBasic(CompilerTest):
def test_assignexpr_single_eval(self):
m... | 4 | assert | numeric_literal | spy/tests/compiler/test_basic.py | test_assignexpr_single_eval | TestBasic | 180 | null |
spylang/spy | import textwrap
from typing import Any
import pytest
from spy import ast
from spy.analyze.scope import ScopeAnalyzer
from spy.analyze.symtable import (
Color,
ImportRef,
Symbol,
SymTable,
VarKind,
VarKindOrigin,
VarStorage,
)
from spy.fqn import FQN
from spy.parser import Parser
from spy.t... | {"_dict"} | assert | collection | spy/tests/test_scope.py | test_dict_literal | TestScopeAnalyzer | 682 | null |
spylang/spy | from spy.tests.support import CompilerTest, no_C
from spy.vm.builtin import builtin_method
from spy.vm.opspec import W_MetaArg, W_OpSpec
from spy.vm.primitive import W_I32
from spy.vm.registry import ModuleRegistry
from spy.vm.vm import SPyVM
from spy.vm.w import W_Object
class TestItemop(CompilerTest):
SKIP_SPY_B... | 0 | assert | numeric_literal | spy/tests/compiler/operator/test_itemop.py | test_2darray | TestItemop | 130 | null |
spylang/spy | import os
from typing import Any, no_type_check
import py.path
import pytest
from spy.util import (
ANYTHING,
OrderedSet,
cleanup_spyc_files,
extend,
func_equals,
magic_dispatch,
shortrepr,
)
class Test_cleanup_spyc_files:
def test_cleanup_non_verbose(self, tmpdir, capsys):
t... | "" | assert | string_literal | spy/tests/test_util.py | test_cleanup_non_verbose | Test_cleanup_spyc_files | 282 | null |
spylang/spy | from spy.tests.support import CompilerTest, expect_errors, only_interp
class TestImporting(CompilerTest):
SKIP_SPY_BACKEND_SANITY_CHECK = True
def test_type_in_other_module(self):
src = """
@struct
class Point:
x: i32
y: i32
"""
self.write_file("... | 7 | assert | numeric_literal | spy/tests/compiler/test_importing.py | test_type_in_other_module | TestImporting | 89 | null |
spylang/spy | from spy.fqn_parser import FQN, tokenize
def test_single_unqualified_part():
fqn = FQN("foo")
assert len(fqn.parts) == 1
assert fqn.parts[0].name == "foo"
assert fqn.parts[0].qualifiers == | () | assert | collection | spy/tests/test_fqn_parser.py | test_single_unqualified_part | 15 | null | |
spylang/spy | from spy.fqn_parser import FQN, tokenize
def test_single_unqualified_part():
fqn = FQN("foo")
assert len(fqn.parts) == | 1 | assert | numeric_literal | spy/tests/test_fqn_parser.py | test_single_unqualified_part | 13 | null | |
spylang/spy | import re
from spy.errors import SPyError
from spy.tests.support import CompilerTest, skip_backends
class TestStr(CompilerTest):
def test_getitem(self):
mod = self.compile("""
def foo(a: str, i: i32) -> str:
return a[i]
""")
assert mod.foo("ABCDE", 0) == "A"
as... | "E" | assert | string_literal | spy/tests/compiler/test_str.py | test_getitem | TestStr | 62 | null |
spylang/spy | import re
from spy.errors import SPyError
from spy.tests.support import CompilerTest, skip_backends
class TestStr(CompilerTest):
def test_str_numbers(self):
# NOTE: float2str produces slightly different results in Python vs C
# backend: e.g. str(0.0) == '0' in Pytohn, '0.0' in the C backend.
... | "127" | assert | string_literal | spy/tests/compiler/test_str.py | test_str_numbers | TestStr | 134 | null |
spylang/spy | import re
import pytest
from spy.errors import SPyError
from spy.tests.support import CompilerTest, skip_backends
class TestDynamic(CompilerTest):
def test_binop(self):
mod = self.compile("""
def add(x: dynamic, y: dynamic) -> dynamic: return x + y
def sub(x: dynamic, y: dynamic) -... | 5 | assert | numeric_literal | spy/tests/compiler/test_dynamic.py | test_binop | TestDynamic | 78 | null |
spylang/spy | from spy.tests.support import CompilerTest, expect_errors, only_interp
from spy.vm.b import B
from spy.vm.opimpl import W_OpImpl
from spy.vm.opspec import W_MetaArg, W_OpSpec
class TestOpSpec(CompilerTest):
def test_OpSpec_with_args(self):
mod = self.compile("""
from operator import OpSpec, MetaAr... | "blue" | assert | string_literal | spy/tests/compiler/test_opspec.py | test_OpSpec_with_args | TestOpSpec | 47 | null |
spylang/spy | import fixedint
import pytest
from spy.fqn import FQN
from spy.tests.support import expect_errors
from spy.vm.b import B
from spy.vm.builtin import builtin_type
from spy.vm.exc import W_Exception
from spy.vm.object import W_Object, W_Type
from spy.vm.primitive import W_I32, W_Bool, W_NoneType
from spy.vm.str import W_... | W_A._w | assert | complex_expr | spy/tests/vm/test_vm.py | test_w_base | TestVM | 78 | null |
spylang/spy | import pytest
from spy.tests.support import CompilerTest
class TestArray(CompilerTest):
def test_zeros(self):
src = """
from array import zeros
def test_len(n: i32) -> i32:
a = zeros[f64](n)
return len(a)
def test_content(n: i32) -> f64:
a = z... | 5 | assert | numeric_literal | spy/tests/stdlib/test_array.py | test_zeros | TestArray | 98 | null |
spylang/spy | import pytest
from spy.errors import SPyError
from spy.tests.support import CompilerTest, expect_errors, only_interp
from spy.vm.b import B
from spy.vm.modules.__spy__.interp_tuple import W_InterpTuple
class TestTuple(CompilerTest):
def test_unpacking_blue(self):
mod = self.compile("""
@blue
... | 3 | assert | numeric_literal | spy/tests/compiler/test_tuple.py | test_unpacking_blue | TestTuple | 52 | null |
spylang/spy | from spy.fqn import FQN
from spy.tests.support import CompilerTest, expect_errors, no_C, only_interp
from spy.vm.b import B
from spy.vm.object import W_Type
class TestList(CompilerTest):
@no_C
def test_empty_list_singleton(self):
src = """
import __spy__
def get_empty() -> __spy__.Emp... | w_b | assert | variable | spy/tests/compiler/test_list.py | test_empty_list_singleton | TestList | 135 | null |
spylang/spy | from spy.fqn_parser import FQN, tokenize
def test_single_unqualified_part():
fqn = FQN("foo")
assert len(fqn.parts) == 1
assert fqn.parts[0].name == "foo"
assert fqn.parts[0].qualifiers == ()
assert fqn.parts[0].suffix == | "" | assert | string_literal | spy/tests/test_fqn_parser.py | test_single_unqualified_part | 16 | null | |
spylang/spy | import pytest
from spy.errors import SPyError
from spy.tests.support import CompilerTest
def int_type(request):
return request.param
class TestInt(CompilerTest):
def test_binop(self, int_type):
mod = self.compile(f"""
T = {int_type}
def add(x: T, y: T) -> T: return x + y
... | 3 | assert | numeric_literal | spy/tests/compiler/test_int.py | test_binop | TestInt | 74 | null |
spylang/spy | import re
import pytest
from spy.errors import SPyError
from spy.tests.support import CompilerTest, skip_backends
class TestDynamic(CompilerTest):
def test_cmp(self):
mod = self.compile("""
def eq (x: dynamic, y: dynamic) -> dynamic: return x == y
def neq(x: dynamic, y: dynamic) -> dynam... | True | assert | bool_literal | spy/tests/compiler/test_dynamic.py | test_cmp | TestDynamic | 106 | null |
spylang/spy | import pytest
from spy.tests.support import CompilerTest, expect_errors, no_C, only_interp
from spy.vm.builtin import builtin_method
from spy.vm.opspec import W_MetaArg, W_OpSpec
from spy.vm.primitive import W_I32, W_Dynamic
from spy.vm.registry import ModuleRegistry
from spy.vm.vm import SPyVM
from spy.vm.w import W_... | hash(2) | assert | func_call | spy/tests/compiler/test_builtins.py | test_hash | TestBuiltins | 116 | null |
spylang/spy | import textwrap
import py.path
import pytest
from spy import ast
from spy.analyze import importing
from spy.analyze.importing import SPYC_VERSION, ImportAnalyzer
from spy.vm.vm import SPyVM
class TestImportAnalyzer:
def init(self, tmpdir):
self.vm = SPyVM()
self.vm.path = [str(tmpdir)]
s... | "load" | assert | string_literal | spy/tests/test_import_analyzer.py | test_cache_version_mismatch | TestImportAnalyzer | 257 | null |
spylang/spy | import pytest
from spy.tests.support import CompilerTest, expect_errors, no_C, only_interp
from spy.vm.builtin import builtin_method
from spy.vm.opspec import W_MetaArg, W_OpSpec
from spy.vm.primitive import W_I32, W_Dynamic
from spy.vm.registry import ModuleRegistry
from spy.vm.vm import SPyVM
from spy.vm.w import W_... | 5 | assert | numeric_literal | spy/tests/compiler/test_builtins.py | test_len | TestBuiltins | 70 | null |
spylang/spy | import pytest
from spy.fqn import FQN
from spy.tests.support import CompilerTest, no_C
from spy.vm.b import B
from spy.vm.modules.__spy__.interp_dict import W_InterpDictType
class TestInterpDict(CompilerTest):
def test_new(self):
mod = self.compile("""
from __spy__ import interp_dict
def... | {} | assert | collection | spy/tests/compiler/__spy__/test_interp_dict.py | test_new | TestInterpDict | 33 | null |
spylang/spy | from typing import no_type_check
from spy.fqn import FQN
from spy.vm.b import B
from spy.vm.function import Color, FuncKind, FuncParam, W_ASTFunc
from spy.vm.object import W_Type
from spy.vm.vm import SPyVM
from spy.vm.w import W_FuncType
def make_FuncType(
*types_w: W_Type,
w_restype: W_Type,
color: Colo... | hash(w_ft2) | assert | func_call | spy/tests/vm/test_function.py | test_FunctionType_cache | TestFunction | 49 | null |
spylang/spy | from spy.fqn_parser import FQN, tokenize
def test_single_unqualified_part():
fqn = FQN("foo")
assert len(fqn.parts) == 1
assert fqn.parts[0].name == | "foo" | assert | string_literal | spy/tests/test_fqn_parser.py | test_single_unqualified_part | 14 | null | |
spylang/spy | from spy.fqn import FQN
from spy.tests.support import CompilerTest, expect_errors, no_C, only_interp
from spy.vm.b import B
from spy.vm.object import W_Type
class TestList(CompilerTest):
@only_interp
def test_list_MetaArg(self):
src = """
from operator import MetaArg
def foo() -> list... | 2 | assert | numeric_literal | spy/tests/compiler/test_list.py | test_list_MetaArg | TestList | 88 | null |
spylang/spy | import struct
from spy.libspy import LLSPyInstance, SPyError
from spy.llwasm import LLWasmModule
from spy.tests.support import CTest
def mk_spy_Str(utf8: bytes) -> bytes:
"""
Return the spy_Str representation of the given utf8 bytes.
For example, for b'hello' we have the following in-memory repr:
... | mk_spy_Str(b"hello ") | assert | func_call | spy/tests/test_libspy.py | test_str | TestLibSPy | 62 | null |
spylang/spy | import re
import pytest
from spy.errors import SPyError
from spy.tests.support import CompilerTest, skip_backends
class TestDynamic(CompilerTest):
def test_binop(self):
mod = self.compile("""
def add(x: dynamic, y: dynamic) -> dynamic: return x + y
def sub(x: dynamic, y: dynamic) -... | 2 | assert | numeric_literal | spy/tests/compiler/test_dynamic.py | test_binop | TestDynamic | 73 | null |
spylang/spy | from typing import Any
from spy.tests.support import CompilerTest, no_C
from spy.vm.builtin import builtin_method
from spy.vm.opspec import W_MetaArg, W_OpSpec
from spy.vm.primitive import W_I32
from spy.vm.registry import ModuleRegistry
from spy.vm.vm import SPyVM
from spy.vm.w import W_Object
class TestOperatorBino... | 4 | assert | numeric_literal | spy/tests/compiler/operator/test_binop.py | test_bitwise_ops | TestOperatorBinop | 243 | null |
spylang/spy | import re
import pytest
from spy.errors import SPyError
from spy.tests.support import CompilerTest, skip_backends
class TestDynamic(CompilerTest):
def test_bitwise(self):
mod = self.compile("""
def shl(x: dynamic, y: dynamic) -> dynamic: return x << y
def shr(x: dynamic, y: dynamic) ->... | 16 ^ 0 | assert | complex_expr | spy/tests/compiler/test_dynamic.py | test_bitwise | TestDynamic | 95 | null |
spylang/spy | from spy.tests.support import CompilerTest, only_py_cffi
class TestPyCFFI(CompilerTest):
def test_simple(self):
mod = self.compile("""
def add(x: i32, y: i32) -> i32:
return x + y
""")
assert mod.__name__ == | "test" | assert | string_literal | spy/tests/compiler/test_py_cffi.py | test_simple | TestPyCFFI | 11 | null |
spylang/spy | import pytest
from spy.errors import SPyError
from spy.tests.support import CompilerTest
def int_type(request):
return request.param
class TestInt(CompilerTest):
def test_float_to_int(self):
mod = self.compile("""
def to_i32(x: f64) -> i32: return i32(x)
""")
MAX = 2**31 - 1
... | 0 | assert | numeric_literal | spy/tests/compiler/test_int.py | test_float_to_int | TestInt | 62 | null |
spylang/spy | from math import isclose, isnan
import pytest
from spy.errors import SPyError
from spy.tests.support import CompilerTest
def int_type(request):
return request.param
class TestUnsafeIntDiv(CompilerTest):
def test_unchecked_floordiv(self, int_type):
mod = self.compile(f"""
from unsafe import ... | 7 | assert | numeric_literal | spy/tests/compiler/unsafe/test_div.py | test_unchecked_floordiv | TestUnsafeIntDiv | 41 | null |
spylang/spy | from typing import Any
from spy.tests.support import CompilerTest, no_C
from spy.vm.builtin import builtin_method
from spy.vm.opspec import W_MetaArg, W_OpSpec
from spy.vm.primitive import W_I32
from spy.vm.registry import ModuleRegistry
from spy.vm.vm import SPyVM
from spy.vm.w import W_Object
class TestOperatorBino... | 0 | assert | numeric_literal | spy/tests/compiler/operator/test_binop.py | test_eq_ne | TestOperatorBinop | 279 | null |
spylang/spy | import textwrap
from typing import Any
import pytest
from spy import ast
from spy.analyze.scope import ScopeAnalyzer
from spy.analyze.symtable import (
Color,
ImportRef,
Symbol,
SymTable,
VarKind,
VarKindOrigin,
VarStorage,
)
from spy.fqn import FQN
from spy.parser import Parser
from spy.t... | "blue" | assert | string_literal | spy/tests/test_scope.py | test_global | TestScopeAnalyzer | 94 | null |
spylang/spy | from typing import Any
from spy.tests.support import CompilerTest, no_C
from spy.vm.builtin import builtin_method
from spy.vm.opspec import W_MetaArg, W_OpSpec
from spy.vm.primitive import W_I32
from spy.vm.registry import ModuleRegistry
from spy.vm.vm import SPyVM
from spy.vm.w import W_Object
class TestOperatorBino... | 5 | assert | numeric_literal | spy/tests/compiler/operator/test_binop.py | test_div | TestOperatorBinop | 211 | null |
spylang/spy | import textwrap
import py.path
import pytest
from spy import ast
from spy.analyze import importing
from spy.analyze.importing import SPYC_VERSION, ImportAnalyzer
from spy.vm.vm import SPyVM
class TestImportAnalyzer:
def init(self, tmpdir):
self.vm = SPyVM()
self.vm.path = [str(tmpdir)]
s... | "main" | assert | string_literal | spy/tests/test_import_analyzer.py | test_analyze_scopes | TestImportAnalyzer | 129 | null |
spylang/spy | from spy.fqn import FQN, NSPart
def test_FQN_hash_eq():
a = FQN("aaa::bbb")
b = FQN("aaa::bbb")
assert a == b
assert hash(a) == hash(b)
a0 = FQN("aaa::bbb#0")
b0 = FQN("aaa::bbb#0")
assert a0 == b0
assert hash(a0) == | hash(b0) | assert | func_call | spy/tests/test_fqn.py | test_FQN_hash_eq | 42 | null | |
spylang/spy | from spy.fqn import FQN
from spy.tests.support import CompilerTest, only_interp
from spy.vm.b import B
from spy.vm.modules.__spy__.interp_dict import W_InterpDict
from spy.vm.object import W_Type
class TestDict(CompilerTest):
@only_interp
def test_empty_dict_to_interp_dict(self):
src = """
fro... | {} | assert | collection | spy/tests/compiler/test_dict.py | test_empty_dict_to_interp_dict | TestDict | 85 | null |
spylang/spy | from spy.tests.support import CompilerTest, expect_errors, only_interp
from spy.vm.b import B
from spy.vm.opimpl import W_OpImpl
from spy.vm.opspec import W_MetaArg, W_OpSpec
class TestOpSpec(CompilerTest):
def test_new_MetaArg(self):
mod = self.compile("""
from operator import MetaArg
@b... | "red" | assert | string_literal | spy/tests/compiler/test_opspec.py | test_new_MetaArg | TestOpSpec | 76 | null |
spylang/spy | import pytest
from spy.fqn import FQN
from spy.tests.support import CompilerTest, no_C
from spy.vm.b import B
from spy.vm.modules.__spy__.interp_dict import W_InterpDictType
class TestInterpDict(CompilerTest):
def test_eq(self):
mod = self.compile("""
from __spy__ import interp_dict
def ... | True | assert | bool_literal | spy/tests/compiler/__spy__/test_interp_dict.py | test_eq | TestInterpDict | 60 | null |
spylang/spy | import pytest
from spy.tests.support import CompilerTest, expect_errors, no_C, only_interp
from spy.vm.builtin import builtin_method
from spy.vm.opspec import W_MetaArg, W_OpSpec
from spy.vm.primitive import W_I32, W_Dynamic
from spy.vm.registry import ModuleRegistry
from spy.vm.vm import SPyVM
from spy.vm.w import W_... | w_b | assert | variable | spy/tests/compiler/test_builtins.py | test_builtin_func_dedup | TestBuiltins | 156 | null |
spylang/spy | import pytest
from spy.errors import SPyError
from spy.tests.support import CompilerTest
class TestList(CompilerTest):
def test_basic_operations(self):
src = """
from _list import list
def test_empty() -> int:
lst = list[int]()
return len(lst)
def test_app... | 0 | assert | numeric_literal | spy/tests/stdlib/test__list.py | test_basic_operations | TestList | 24 | null |
spylang/spy | import pytest
from spy.errors import SPyError
from spy.tests.support import (
CompilerTest,
expect_errors,
no_C,
only_interp,
skip_backends,
)
from spy.vm.exc import FrameInfo
class TestException(CompilerTest):
def test_raise(self):
# for now, we don't support "except:", and raising an... | "" | assert | string_literal | spy/tests/compiler/test_exception.py | test_raise | TestException | 57 | null |
spylang/spy | import pytest
from spy.errors import SPyError
from spy.tests.support import CompilerTest
class TestList(CompilerTest):
def test_extend(self):
src = """
from _list import list
def test_extend() -> str:
lst1 = list[int]()
lst1.append(10)
lst1.append(20)
... | 1 | assert | numeric_literal | spy/tests/stdlib/test__list.py | test_extend | TestList | 348 | null |
spylang/spy | import pytest
from spy.errors import SPyError
from spy.tests.support import CompilerTest, expect_errors, no_C
class TestInterpTuple(CompilerTest):
def test_getitem(self):
mod = self.compile("""
from __spy__ import interp_tuple
def foo(i: i32) -> dynamic:
tup = interp_tuple(1,... | 1 | assert | numeric_literal | spy/tests/compiler/__spy__/test_interp_tuple.py | test_getitem | TestInterpTuple | 28 | null |
spylang/spy | import pytest
from spy.errors import SPyError
from spy.tests.support import CompilerTest
class TestList(CompilerTest):
def test_index(self):
src = """
from _list import list
def test_middle() -> int:
lst = list[int]()
lst.append(10)
lst.append(20)
... | 2 | assert | numeric_literal | spy/tests/stdlib/test__list.py | test_index | TestList | 489 | null |
spylang/spy | import pytest
from spy.tests.support import CompilerTest
class TestArray(CompilerTest):
def test_len(self):
src = """
from array import array
def test1() -> int:
a = array[int, 1](3)
return len(a)
def test2() -> int:
a = array[int, 2](4, 5)
... | 4 | assert | numeric_literal | spy/tests/stdlib/test_array.py | test_len | TestArray | 52 | null |
spylang/spy | import pytest
from spy.fqn import FQN
from spy.tests.support import CompilerTest, no_C
from spy.vm.b import B
from spy.vm.modules.__spy__.interp_list import W_InterpListType
class TestInterpList(CompilerTest):
def test_getitem(self):
mod = self.compile("""
from __spy__ import interp_list
... | "bar" | assert | string_literal | spy/tests/compiler/__spy__/test_interp_list.py | test_getitem | TestInterpList | 51 | null |
spylang/spy | from typing import Any
import pytest
from spy.errors import SPyError
from spy.fqn import FQN
from spy.tests.support import (
CompilerTest,
expect_errors,
no_C,
only_interp,
skip_backends,
)
from spy.vm.b import B
class TestBasic(CompilerTest):
def test_assignexpr_updates_cell(self):
... | 2 | assert | numeric_literal | spy/tests/compiler/test_basic.py | test_assignexpr_updates_cell | TestBasic | 164 | null |
spylang/spy | import math
from spy.tests.support import CompilerTest
class TestMath(CompilerTest):
def test_sqrt(self):
mod = self.compile("""
from math import sqrt
def foo(x: f64) -> f64:
return sqrt(x)
""")
assert mod.foo(64.0) == | 8 | assert | numeric_literal | spy/tests/compiler/test_math.py | test_sqrt | TestMath | 14 | null |
spylang/spy | import pytest
from spy.errors import SPyError
from spy.fqn import FQN
from spy.tests.support import CompilerTest, expect_errors, only_interp
from spy.tests.wasm_wrapper import WasmPtr
from spy.vm.b import B
from spy.vm.modules.unsafe import UNSAFE
from spy.vm.object import W_Type
from spy.vm.registry import ModuleRegi... | dt | assert | variable | spy/tests/compiler/test_struct.py | test_dir | TestStructOnStack | 345 | null |
spylang/spy | from spy.fqn import FQN, NSPart
def test_qualifiers():
a = FQN("a::b[x, y]::c")
assert a.fullname == "a::b[x, y]::c"
assert a.modname == | "a" | assert | string_literal | spy/tests/test_fqn.py | test_qualifiers | 48 | null | |
spylang/spy | import textwrap
import pytest
from spy.backend.spy import FQN_FORMAT, SPyBackend
from spy.util import print_diff
from spy.vm.vm import SPyVM
class TestDoppler:
def init(self, tmpdir):
# XXX there is a lot of code duplication with CompilerTest
self.tmpdir = tmpdir
self.vm = SPyVM()
... | 3 | assert | numeric_literal | spy/tests/test_doppler.py | test_ast_color_map_populated | TestDoppler | 376 | null |
spylang/spy | import re
from spy.errors import SPyError
from spy.tests.support import CompilerTest, skip_backends
class TestStr(CompilerTest):
def test_str_numbers(self):
# NOTE: float2str produces slightly different results in Python vs C
# backend: e.g. str(0.0) == '0' in Pytohn, '0.0' in the C backend.
... | "0" | assert | string_literal | spy/tests/compiler/test_str.py | test_str_numbers | TestStr | 136 | null |
spylang/spy | from typing import Any
from spy.tests.support import CompilerTest, no_C
from spy.vm.builtin import builtin_method
from spy.vm.opspec import W_MetaArg, W_OpSpec
from spy.vm.primitive import W_I32
from spy.vm.registry import ModuleRegistry
from spy.vm.vm import SPyVM
from spy.vm.w import W_Object
class TestOperatorBino... | 1 | assert | numeric_literal | spy/tests/compiler/operator/test_binop.py | test_mod | TestOperatorBinop | 223 | null |
spylang/spy | import pytest
from spy.tests.support import CompilerTest, expect_errors, no_C, only_interp
from spy.vm.builtin import builtin_method
from spy.vm.opspec import W_MetaArg, W_OpSpec
from spy.vm.primitive import W_I32, W_Dynamic
from spy.vm.registry import ModuleRegistry
from spy.vm.vm import SPyVM
from spy.vm.w import W_... | hash(x) | assert | func_call | spy/tests/compiler/test_builtins.py | test_hash | TestBuiltins | 118 | null |
spylang/spy | import pytest
from spy.errors import SPyError
from spy.tests.support import CompilerTest
def int_type(request):
return request.param
class TestInt(CompilerTest):
def test_binop(self, int_type):
mod = self.compile(f"""
T = {int_type}
def add(x: T, y: T) -> T: return x + y
... | 5 | assert | numeric_literal | spy/tests/compiler/test_int.py | test_binop | TestInt | 79 | null |
spylang/spy | import pytest
from spy.tests.support import CompilerTest, expect_errors, no_C, only_interp
from spy.vm.builtin import builtin_method
from spy.vm.opspec import W_MetaArg, W_OpSpec
from spy.vm.primitive import W_I32, W_Dynamic
from spy.vm.registry import ModuleRegistry
from spy.vm.vm import SPyVM
from spy.vm.w import W_... | dm | assert | variable | spy/tests/compiler/test_builtins.py | test_dir | TestBuiltins | 285 | null |
spylang/spy | from typing import Any
import pytest
from spy.errors import SPyError
from spy.fqn import FQN
from spy.tests.support import (
CompilerTest,
expect_errors,
no_C,
only_interp,
skip_backends,
)
from spy.vm.b import B
class TestBasic(CompilerTest):
def test_binop(self):
mod = self.compile... | 3 | assert | numeric_literal | spy/tests/compiler/test_basic.py | test_binop | TestBasic | 119 | null |
spylang/spy | from typing import Any
import pytest
from spy.errors import SPyError
from spy.fqn import FQN
from spy.tests.support import (
CompilerTest,
expect_errors,
no_C,
only_interp,
skip_backends,
)
from spy.vm.b import B
class TestBasic(CompilerTest):
@pytest.mark.skip(reason="the result of op.ADD s... | 8 | assert | numeric_literal | spy/tests/compiler/test_basic.py | test_explicit_BinOp | TestBasic | 436 | null |
spylang/spy | import re
import pytest
from spy.tests.support import CompilerTest, only_C
class TestDebug(CompilerTest):
RE_SPY_LINE = re.compile(r"#line SPY_LINE\((\d+), (\d+)\)")
def test_debug_info(self):
self.compile("""
def foo() -> i32: # line 2 <==
x: i32 = 3 # line 3 <==
... | [2, 3, 7] | assert | collection | spy/tests/compiler/test_debug.py | test_debug_info | TestDebug | 38 | null |
spylang/spy | import pytest
from spy.errors import SPyError
from spy.fqn import FQN
from spy.tests.support import (
CompilerTest,
expect_errors,
no_C,
only_interp,
skip_backends,
)
from spy.vm.b import B
class TestMetaFunc(CompilerTest):
@no_C
def test_STATIC_TYPE_side_effects(self):
if self.ba... | 1 | assert | numeric_literal | spy/tests/compiler/test_metafunc.py | test_STATIC_TYPE_side_effects | TestMetaFunc | 122 | null |
spylang/spy | from spy.location import Loc
def myfunc() -> Loc:
loc = Loc.here()
return loc
def test_Loc_here():
loc = myfunc()
src = loc.get_src()
exp = " loc = Loc.here()"
assert src == | exp | assert | variable | spy/tests/test_loc.py | test_Loc_here | 13 | null | |
spylang/spy | import pytest
from spy.fqn import FQN
from spy.tests.support import CompilerTest, no_C
from spy.vm.b import B
from spy.vm.modules.__spy__.interp_dict import W_InterpDictType
class TestInterpDict(CompilerTest):
def test_repr_str(self):
mod = self.compile("""
from __spy__ import interp_dict
... | "{}" | assert | string_literal | spy/tests/compiler/__spy__/test_interp_dict.py | test_repr_str | TestInterpDict | 96 | null |
spylang/spy | import re
from spy.errors import SPyError
from spy.tests.support import CompilerTest, skip_backends
class TestStr(CompilerTest):
def test_str_numbers(self):
# NOTE: float2str produces slightly different results in Python vs C
# backend: e.g. str(0.0) == '0' in Pytohn, '0.0' in the C backend.
... | "-10" | assert | string_literal | spy/tests/compiler/test_str.py | test_str_numbers | TestStr | 131 | null |
spylang/spy | import pytest
from spy.fqn import FQN
from spy.tests.support import CompilerTest, no_C
from spy.vm.b import B
from spy.vm.modules.__spy__.interp_list import W_InterpListType
class TestInterpList(CompilerTest):
def test_new(self):
mod = self.compile("""
from __spy__ import interp_list
def... | [] | assert | collection | spy/tests/compiler/__spy__/test_interp_list.py | test_new | TestInterpList | 38 | null |
spylang/spy | from textwrap import dedent
from spy.tests.support import CompilerTest, only_interp
from spy.vm.struct import UnwrappedStruct
class TestSlice(CompilerTest):
def test__slice_module(self):
src = """
def make_slice() -> slice:
return slice(0,1,2)
def make_slice_none() -> slice:
... | (0, 0, 0) | assert | collection | spy/tests/stdlib/test__slice.py | test__slice_module | TestSlice | 21 | null |
spylang/spy | import pytest
from spy.tests.support import CompilerTest
class TestArray(CompilerTest):
def test_array2_simple(self):
src = """
from array import array
def test() -> int:
a = array[int, 2](2, 3)
a[0, 0] = 1
a[0, 1] = 2
a[0, 2] = 3
... | 7 | assert | numeric_literal | spy/tests/stdlib/test_array.py | test_array2_simple | TestArray | 36 | null |
spylang/spy | import re
from spy.errors import SPyError
from spy.tests.support import CompilerTest, skip_backends
class TestStr(CompilerTest):
def test_len(self):
src = """
def foo(s: str) -> i32:
return len(s)
"""
mod = self.compile(src)
assert mod.foo("") == 0
ass... | 3 | assert | numeric_literal | spy/tests/compiler/test_str.py | test_len | TestStr | 88 | null |
spylang/spy | import textwrap
import pytest
from spy.textbuilder import ColorFormatter, TextBuilder
class TestTextBuilder:
def test_simple(self):
b = TextBuilder()
assert b.build() == | "" | assert | string_literal | spy/tests/test_textbuilder.py | test_simple | TestTextBuilder | 11 | null |
spylang/spy | import textwrap
import pytest
from spy.textbuilder import ColorFormatter, TextBuilder
class TestTextBuilder:
def test_lineno(self):
b = TextBuilder()
assert b.lineno == 1
b.wl("one")
assert b.lineno == | 2 | assert | numeric_literal | spy/tests/test_textbuilder.py | test_lineno | TestTextBuilder | 166 | null |
spylang/spy | import pytest
from spy.errors import SPyError
from spy.tests.support import CompilerTest
class TestList(CompilerTest):
def test_getitem(self):
src = """
from _list import list
def test_indexing() -> int:
lst = list[int]()
lst.append(100)
lst.append(200... | 9 | assert | numeric_literal | spy/tests/stdlib/test__list.py | test_getitem | TestList | 89 | null |
spylang/spy | import os
from typing import Any, no_type_check
import py.path
import pytest
from spy.util import (
ANYTHING,
OrderedSet,
cleanup_spyc_files,
extend,
func_equals,
magic_dispatch,
shortrepr,
)
def test_magic_dispatch():
class Foo:
def visit(self, obj: Any, arg: int) -> Any:
... | 9 | assert | numeric_literal | spy/tests/test_util.py | test_magic_dispatch | 56 | null | |
spylang/spy | from typing import Any
import pytest
from spy.errors import SPyError
from spy.fqn import FQN
from spy.tests.support import (
CompilerTest,
expect_errors,
no_C,
only_interp,
skip_backends,
)
from spy.vm.b import B
class TestBasic(CompilerTest):
def test_assignexpr_updates_cell(self):
... | 1 | assert | numeric_literal | spy/tests/compiler/test_basic.py | test_assignexpr_updates_cell | TestBasic | 162 | null |
spylang/spy | import pytest
from spy.errors import SPyError
from spy.tests.support import CompilerTest, expect_errors, only_interp
from spy.vm.b import B
from spy.vm.modules.__spy__.interp_tuple import W_InterpTuple
class TestTuple(CompilerTest):
@only_interp
def test_literal_interp_tuple(self):
mod = self.compile... | B.w_i32 | assert | complex_expr | spy/tests/compiler/test_tuple.py | test_literal_interp_tuple | TestTuple | 39 | null |
spylang/spy | import pytest
from spy.errors import SPyError
from spy.tests.support import CompilerTest
def int_type(request):
return request.param
class TestInt(CompilerTest):
def test_division_mixed_signs(self, int_type):
if int_type in ("u8", "u32"):
pytest.skip("Skipping for negative operands in fl... | 2 | assert | numeric_literal | spy/tests/compiler/test_int.py | test_division_mixed_signs | TestInt | 106 | null |
spylang/spy | from spy.tests.support import CompilerTest
class TestPosix(CompilerTest):
def test_get_terminal_size(self):
mod = self.compile("""
from posix import TerminalSize, get_terminal_size
def foo() -> str:
size: TerminalSize = get_terminal_size()
return str(size.lines) + "... | 2 | assert | numeric_literal | spy/tests/compiler/test_posix.py | test_get_terminal_size | TestPosix | 15 | null |
spylang/spy | from math import isclose, isnan
import pytest
from spy.errors import SPyError
from spy.tests.support import CompilerTest
def int_type(request):
return request.param
class TestUnsafeIntDiv(CompilerTest):
def test_unchecked_mod(self, int_type):
mod = self.compile(f"""
from unsafe import unche... | 1 | assert | numeric_literal | spy/tests/compiler/unsafe/test_div.py | test_unchecked_mod | TestUnsafeIntDiv | 50 | null |
spylang/spy | import struct
from spy.libspy import LLSPyInstance, SPyError
from spy.llwasm import LLWasmModule
from spy.tests.support import CTest
def mk_spy_Str(utf8: bytes) -> bytes:
"""
Return the spy_Str representation of the given utf8 bytes.
For example, for b'hello' we have the following in-memory repr:
... | mk_spy_Str(b"hello world") | assert | func_call | spy/tests/test_libspy.py | test_str | TestLibSPy | 68 | null |
spylang/spy | from spy.fqn import FQN, NSPart
def test_FQN_human_name():
# see also tests/vm/test_function.py::test_FunctionType_fqn
assert FQN("a::b").human_name == "a::b"
assert FQN("builtins::i32").human_name == | "i32" | assert | string_literal | spy/tests/test_fqn.py | test_FQN_human_name | 100 | null | |
spylang/spy | from typing import Annotated
import pytest
from spy.errors import SPyError
from spy.fqn import FQN
from spy.vm.b import B
from spy.vm.builtin import (
builtin_class_attr,
builtin_method,
builtin_type,
functype_from_sig,
)
from spy.vm.object import W_Object
from spy.vm.primitive import W_I32, W_Dynamic... | B.w_None | assert | complex_expr | spy/tests/vm/test_builtin.py | test_return_None | TestBuiltin | 107 | null |
spylang/spy | from spy.tests.support import CompilerTest, no_C
from spy.vm.builtin import builtin_method
from spy.vm.opspec import W_MetaArg, W_OpSpec
from spy.vm.primitive import W_I32
from spy.vm.registry import ModuleRegistry
from spy.vm.vm import SPyVM
from spy.vm.w import W_Object
class TestOperatorUnaryOp(CompilerTest):
S... | True | assert | bool_literal | spy/tests/compiler/operator/test_unaryop.py | test_not | TestOperatorUnaryOp | 61 | null |
spylang/spy | import pytest
from spy.fqn import FQN
from spy.tests.support import CompilerTest, no_C
from spy.vm.b import B
from spy.vm.modules.__spy__.interp_list import W_InterpListType
class TestInterpList(CompilerTest):
def test_eq(self):
if self.backend == "doppler":
pytest.skip("list PBCs not support... | True | assert | bool_literal | spy/tests/compiler/__spy__/test_interp_list.py | test_eq | TestInterpList | 83 | null |
spylang/spy | from textwrap import dedent
from spy.tests.support import CompilerTest, only_interp
from spy.vm.struct import UnwrappedStruct
class TestSlice(CompilerTest):
def test__slice_module(self):
src = """
def make_slice() -> slice:
return slice(0,1,2)
def make_slice_none() -> slice:
... | (0, 1, 2) | assert | collection | spy/tests/stdlib/test__slice.py | test__slice_module | TestSlice | 20 | null |
spylang/spy | from spy.fqn import FQN
from spy.tests.support import CompilerTest, expect_errors, no_C, only_interp
from spy.vm.b import B
from spy.vm.object import W_Type
class TestList(CompilerTest):
@only_interp
def test_list_MetaArg(self):
src = """
from operator import MetaArg
def foo() -> list... | B.w_i32 | assert | complex_expr | spy/tests/compiler/test_list.py | test_list_MetaArg | TestList | 90 | null |
spylang/spy | import re
from spy.errors import SPyError
from spy.tests.support import CompilerTest, skip_backends
class TestStr(CompilerTest):
def test_getitem(self):
mod = self.compile("""
def foo(a: str, i: i32) -> str:
return a[i]
""")
assert mod.foo("ABCDE", 0) == "A"
a... | "B" | assert | string_literal | spy/tests/compiler/test_str.py | test_getitem | TestStr | 61 | null |
spylang/spy | from textwrap import dedent
from spy.tests.support import CompilerTest, only_interp
from spy.vm.struct import UnwrappedStruct
class TestSlice(CompilerTest):
def test__slice_module(self):
src = """
def make_slice() -> slice:
return slice(0,1,2)
def make_slice_none() -> slice:
... | (1, 1, 1) | assert | collection | spy/tests/stdlib/test__slice.py | test__slice_module | TestSlice | 26 | null |
spylang/spy | import pytest
from spy.tests.support import CompilerTest, expect_errors, no_C, only_interp
from spy.vm.builtin import builtin_method
from spy.vm.opspec import W_MetaArg, W_OpSpec
from spy.vm.primitive import W_I32, W_Dynamic
from spy.vm.registry import ModuleRegistry
from spy.vm.vm import SPyVM
from spy.vm.w import W_... | di | assert | variable | spy/tests/compiler/test_builtins.py | test_dir | TestBuiltins | 280 | null |
spylang/spy | from spy.tests.support import CompilerTest, no_C
from spy.vm.builtin import builtin_method
from spy.vm.opspec import W_MetaArg, W_OpSpec
from spy.vm.primitive import W_I32
from spy.vm.registry import ModuleRegistry
from spy.vm.vm import SPyVM
from spy.vm.w import W_Object
class TestOperatorUnaryOp(CompilerTest):
S... | 0 | assert | numeric_literal | spy/tests/compiler/operator/test_unaryop.py | test_neg | TestOperatorUnaryOp | 49 | null |
spylang/spy | from textwrap import dedent
from spy.tests.support import CompilerTest, only_interp
from spy.vm.struct import UnwrappedStruct
class TestSlice(CompilerTest):
def test__slice_module(self):
src = """
def make_slice() -> slice:
return slice(0,1,2)
def make_slice_none() -> slice:
... | str(s.fqn) | assert | func_call | spy/tests/stdlib/test__slice.py | test__slice_module | TestSlice | 19 | null |
spylang/spy | from spy.tests.support import CompilerTest, expect_errors, only_interp
from spy.vm.b import B
from spy.vm.opimpl import W_OpImpl
from spy.vm.opspec import W_MetaArg, W_OpSpec
class TestOpSpec(CompilerTest):
def test_OpSpec_with_args(self):
mod = self.compile("""
from operator import OpSpec, MetaAr... | 1 | assert | numeric_literal | spy/tests/compiler/test_opspec.py | test_OpSpec_with_args | TestOpSpec | 42 | null |
spylang/spy | import os
from typing import Any, no_type_check
import py.path
import pytest
from spy.util import (
ANYTHING,
OrderedSet,
cleanup_spyc_files,
extend,
func_equals,
magic_dispatch,
shortrepr,
)
def test_OrderedSet():
s = OrderedSet[int]()
s.add(3)
s.add(1)
s.add(2)
s.add... | s | assert | variable | spy/tests/test_util.py | test_OrderedSet | 35 | null | |
spylang/spy | from spy.fqn_parser import FQN, tokenize
def test_two_parts():
fqn = FQN("mod::foo")
assert len(fqn.parts) == 2
assert fqn.parts[0].name == | "mod" | assert | string_literal | spy/tests/test_fqn_parser.py | test_two_parts | 22 | null | |
spylang/spy | from spy.fqn_parser import FQN, tokenize
def test_suffix():
fqn = FQN("mod::foo[i32]#1")
assert fqn.parts[0].name == "mod"
assert fqn.parts[1].name == "foo"
assert fqn.parts[1].qualifiers[0].parts[0].name == "i32"
assert fqn.parts[1].suffix == | "1" | assert | string_literal | spy/tests/test_fqn_parser.py | test_suffix | 61 | null | |
spylang/spy | from spy.fqn import FQN, NSPart
def test_FQN_parent():
fqn = FQN("a::b::c")
assert fqn.parent() == | FQN("a::b") | assert | func_call | spy/tests/test_fqn.py | test_FQN_parent | 150 | null | |
spylang/spy | from spy.tests.support import CompilerTest, only_py_cffi
class TestPyCFFI(CompilerTest):
def test_simple(self):
mod = self.compile("""
def add(x: i32, y: i32) -> i32:
return x + y
""")
assert mod.__name__ == "test" # this is 'pyfile'
assert hasattr(mod._test, "f... | 9 | assert | numeric_literal | spy/tests/compiler/test_py_cffi.py | test_simple | TestPyCFFI | 14 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.