@alloy-js/python 0.4.0-dev.3 → 0.4.0-dev.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev/src/builtins/python.js +30 -0
- package/dist/dev/src/builtins/python.js.map +1 -0
- package/dist/dev/src/components/Atom.js +122 -0
- package/dist/dev/src/components/Atom.js.map +1 -0
- package/dist/dev/src/components/CallSignature.js +195 -0
- package/dist/dev/src/components/CallSignature.js.map +1 -0
- package/dist/dev/src/components/ClassDeclaration.js +112 -0
- package/dist/dev/src/components/ClassDeclaration.js.map +1 -0
- package/dist/dev/src/components/ClassInstantiation.js +40 -0
- package/dist/dev/src/components/ClassInstantiation.js.map +1 -0
- package/dist/dev/src/components/ClassMethodDeclaration.js +40 -0
- package/dist/dev/src/components/ClassMethodDeclaration.js.map +1 -0
- package/dist/dev/src/components/ConstructorDeclaration.js +39 -0
- package/dist/dev/src/components/ConstructorDeclaration.js.map +1 -0
- package/dist/dev/src/components/DataclassDeclaration.js +177 -0
- package/dist/dev/src/components/DataclassDeclaration.js.map +1 -0
- package/dist/dev/src/components/Declaration.js +31 -0
- package/dist/dev/src/components/Declaration.js.map +1 -0
- package/dist/dev/src/components/DunderMethodDeclaration.js +33 -0
- package/dist/dev/src/components/DunderMethodDeclaration.js.map +1 -0
- package/dist/dev/src/components/EnumDeclaration.js +259 -0
- package/dist/dev/src/components/EnumDeclaration.js.map +1 -0
- package/dist/dev/src/components/EnumMember.js +95 -0
- package/dist/dev/src/components/EnumMember.js.map +1 -0
- package/dist/dev/src/components/FunctionBase.js +130 -0
- package/dist/dev/src/components/FunctionBase.js.map +1 -0
- package/dist/dev/src/components/FunctionCallExpression.js +53 -0
- package/dist/dev/src/components/FunctionCallExpression.js.map +1 -0
- package/dist/dev/src/components/FunctionDeclaration.js +45 -0
- package/dist/dev/src/components/FunctionDeclaration.js.map +1 -0
- package/dist/dev/src/components/FutureStatement.js +31 -0
- package/dist/dev/src/components/FutureStatement.js.map +1 -0
- package/dist/dev/src/components/ImportStatement.js +167 -0
- package/dist/dev/src/components/ImportStatement.js.map +1 -0
- package/dist/dev/src/components/LexicalScope.js +26 -0
- package/dist/dev/src/components/LexicalScope.js.map +1 -0
- package/dist/dev/src/components/MemberExpression.js +290 -0
- package/dist/dev/src/components/MemberExpression.js.map +1 -0
- package/dist/dev/src/components/MemberScope.js +23 -0
- package/dist/dev/src/components/MemberScope.js.map +1 -0
- package/dist/dev/src/components/MethodBase.js +40 -0
- package/dist/dev/src/components/MethodBase.js.map +1 -0
- package/dist/dev/src/components/MethodDeclaration.js +38 -0
- package/dist/dev/src/components/MethodDeclaration.js.map +1 -0
- package/dist/dev/src/components/PropertyDeclaration.js +287 -0
- package/dist/dev/src/components/PropertyDeclaration.js.map +1 -0
- package/dist/dev/src/components/PyDoc.js +1478 -0
- package/dist/dev/src/components/PyDoc.js.map +1 -0
- package/dist/dev/src/components/PythonBlock.js +35 -0
- package/dist/dev/src/components/PythonBlock.js.map +1 -0
- package/dist/dev/src/components/Reference.js +23 -0
- package/dist/dev/src/components/Reference.js.map +1 -0
- package/dist/dev/src/components/SourceFile.js +385 -0
- package/dist/dev/src/components/SourceFile.js.map +1 -0
- package/dist/dev/src/components/StatementList.js +34 -0
- package/dist/dev/src/components/StatementList.js.map +1 -0
- package/dist/dev/src/components/StaticMethodDeclaration.js +40 -0
- package/dist/dev/src/components/StaticMethodDeclaration.js.map +1 -0
- package/dist/dev/src/components/TypeArguments.js +22 -0
- package/dist/dev/src/components/TypeArguments.js.map +1 -0
- package/dist/dev/src/components/TypeRefContext.js +33 -0
- package/dist/dev/src/components/TypeRefContext.js.map +1 -0
- package/dist/dev/src/components/TypeReference.js +67 -0
- package/dist/dev/src/components/TypeReference.js.map +1 -0
- package/dist/dev/src/components/UnionTypeExpression.js +57 -0
- package/dist/dev/src/components/UnionTypeExpression.js.map +1 -0
- package/dist/dev/src/components/VariableDeclaration.js +150 -0
- package/dist/dev/src/components/VariableDeclaration.js.map +1 -0
- package/dist/dev/src/components/index.js +32 -0
- package/dist/dev/src/components/index.js.map +1 -0
- package/dist/dev/src/context/index.js +2 -0
- package/dist/dev/src/context/index.js.map +1 -0
- package/dist/dev/src/context/type-ref-context.js +17 -0
- package/dist/dev/src/context/type-ref-context.js.map +1 -0
- package/dist/dev/src/create-module.js +64 -0
- package/dist/dev/src/create-module.js.map +1 -0
- package/dist/dev/src/index.js +8 -0
- package/dist/dev/src/index.js.map +1 -0
- package/dist/dev/src/name-conflict-resolver.js +8 -0
- package/dist/dev/src/name-conflict-resolver.js.map +1 -0
- package/dist/dev/src/name-policy.js +48 -0
- package/dist/dev/src/name-policy.js.map +1 -0
- package/dist/dev/src/parameter-descriptor.js +8 -0
- package/dist/dev/src/parameter-descriptor.js.map +1 -0
- package/dist/dev/src/symbol-creation.js +58 -0
- package/dist/dev/src/symbol-creation.js.map +1 -0
- package/dist/dev/src/symbols/factories.js +28 -0
- package/dist/dev/src/symbols/factories.js.map +1 -0
- package/dist/dev/src/symbols/index.js +8 -0
- package/dist/dev/src/symbols/index.js.map +1 -0
- package/dist/dev/src/symbols/python-lexical-scope.js +15 -0
- package/dist/dev/src/symbols/python-lexical-scope.js.map +1 -0
- package/dist/dev/src/symbols/python-member-scope.js +7 -0
- package/dist/dev/src/symbols/python-member-scope.js.map +1 -0
- package/dist/dev/src/symbols/python-module-scope.js +86 -0
- package/dist/dev/src/symbols/python-module-scope.js.map +1 -0
- package/dist/dev/src/symbols/python-output-symbol.js +73 -0
- package/dist/dev/src/symbols/python-output-symbol.js.map +1 -0
- package/dist/dev/src/symbols/reference.js +87 -0
- package/dist/dev/src/symbols/reference.js.map +1 -0
- package/dist/dev/src/symbols/scopes.js +13 -0
- package/dist/dev/src/symbols/scopes.js.map +1 -0
- package/dist/dev/src/utils.js +13 -0
- package/dist/dev/src/utils.js.map +1 -0
- package/dist/dev/test/callsignatures.test.js +482 -0
- package/dist/dev/test/callsignatures.test.js.map +1 -0
- package/dist/dev/test/class-method-declaration.test.js +85 -0
- package/dist/dev/test/class-method-declaration.test.js.map +1 -0
- package/dist/dev/test/classdeclarations.test.js +654 -0
- package/dist/dev/test/classdeclarations.test.js.map +1 -0
- package/dist/dev/test/classinstantiations.test.js +281 -0
- package/dist/dev/test/classinstantiations.test.js.map +1 -0
- package/dist/dev/test/constructordeclaration.test.js +86 -0
- package/dist/dev/test/constructordeclaration.test.js.map +1 -0
- package/dist/dev/test/dataclassdeclarations.test.js +1068 -0
- package/dist/dev/test/dataclassdeclarations.test.js.map +1 -0
- package/dist/dev/test/dundermethoddeclaration.test.js +93 -0
- package/dist/dev/test/dundermethoddeclaration.test.js.map +1 -0
- package/dist/dev/test/enums.test.js +263 -0
- package/dist/dev/test/enums.test.js.map +1 -0
- package/dist/dev/test/externals.test.js +307 -0
- package/dist/dev/test/externals.test.js.map +1 -0
- package/dist/dev/test/factories.test.js +122 -0
- package/dist/dev/test/factories.test.js.map +1 -0
- package/dist/dev/test/functioncallexpressions.test.js +257 -0
- package/dist/dev/test/functioncallexpressions.test.js.map +1 -0
- package/dist/dev/test/functiondeclaration.test.js +817 -0
- package/dist/dev/test/functiondeclaration.test.js.map +1 -0
- package/dist/dev/test/imports.test.js +372 -0
- package/dist/dev/test/imports.test.js.map +1 -0
- package/dist/dev/test/memberexpressions.test.js +1668 -0
- package/dist/dev/test/memberexpressions.test.js.map +1 -0
- package/dist/dev/test/methoddeclaration.test.js +344 -0
- package/dist/dev/test/methoddeclaration.test.js.map +1 -0
- package/dist/dev/test/namepolicies.test.js +154 -0
- package/dist/dev/test/namepolicies.test.js.map +1 -0
- package/dist/dev/test/propertydeclaration.test.js +354 -0
- package/dist/dev/test/propertydeclaration.test.js.map +1 -0
- package/dist/dev/test/pydocs.test.js +1675 -0
- package/dist/dev/test/pydocs.test.js.map +1 -0
- package/dist/dev/test/references.test.js +66 -0
- package/dist/dev/test/references.test.js.map +1 -0
- package/dist/dev/test/sourcefiles.test.js +1802 -0
- package/dist/dev/test/sourcefiles.test.js.map +1 -0
- package/dist/dev/test/staticmethoddeclaration.test.js +85 -0
- package/dist/dev/test/staticmethoddeclaration.test.js.map +1 -0
- package/dist/dev/test/type-checking-imports.test.js +617 -0
- package/dist/dev/test/type-checking-imports.test.js.map +1 -0
- package/dist/dev/test/typereference.test.js +79 -0
- package/dist/dev/test/typereference.test.js.map +1 -0
- package/dist/dev/test/uniontypeexpression.test.js +307 -0
- package/dist/dev/test/uniontypeexpression.test.js.map +1 -0
- package/dist/dev/test/utils.js +100 -0
- package/dist/dev/test/utils.js.map +1 -0
- package/dist/dev/test/values.test.js +182 -0
- package/dist/dev/test/values.test.js.map +1 -0
- package/dist/dev/test/variables.test.js +363 -0
- package/dist/dev/test/variables.test.js.map +1 -0
- package/dist/src/components/CallSignature.d.ts.map +1 -1
- package/dist/src/components/CallSignature.js +12 -3
- package/dist/src/components/CallSignature.js.map +1 -1
- package/dist/src/components/ImportStatement.d.ts +12 -0
- package/dist/src/components/ImportStatement.d.ts.map +1 -1
- package/dist/src/components/ImportStatement.js +45 -3
- package/dist/src/components/ImportStatement.js.map +1 -1
- package/dist/src/components/Reference.d.ts.map +1 -1
- package/dist/src/components/Reference.js +5 -1
- package/dist/src/components/Reference.js.map +1 -1
- package/dist/src/components/SourceFile.d.ts +1 -1
- package/dist/src/components/SourceFile.d.ts.map +1 -1
- package/dist/src/components/SourceFile.js +46 -7
- package/dist/src/components/SourceFile.js.map +1 -1
- package/dist/src/components/TypeRefContext.d.ts +26 -0
- package/dist/src/components/TypeRefContext.d.ts.map +1 -0
- package/dist/src/components/TypeRefContext.js +29 -0
- package/dist/src/components/TypeRefContext.js.map +1 -0
- package/dist/src/components/TypeReference.d.ts +5 -0
- package/dist/src/components/TypeReference.d.ts.map +1 -1
- package/dist/src/components/TypeReference.js +19 -9
- package/dist/src/components/TypeReference.js.map +1 -1
- package/dist/src/components/VariableDeclaration.d.ts.map +1 -1
- package/dist/src/components/VariableDeclaration.js +7 -2
- package/dist/src/components/VariableDeclaration.js.map +1 -1
- package/dist/src/components/index.d.ts +1 -1
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +1 -1
- package/dist/src/components/index.js.map +1 -1
- package/dist/src/context/index.d.ts +2 -0
- package/dist/src/context/index.d.ts.map +1 -0
- package/dist/src/context/index.js +2 -0
- package/dist/src/context/index.js.map +1 -0
- package/dist/src/context/type-ref-context.d.ts +13 -0
- package/dist/src/context/type-ref-context.d.ts.map +1 -0
- package/dist/src/context/type-ref-context.js +17 -0
- package/dist/src/context/type-ref-context.js.map +1 -0
- package/dist/src/symbols/python-module-scope.d.ts +13 -1
- package/dist/src/symbols/python-module-scope.d.ts.map +1 -1
- package/dist/src/symbols/python-module-scope.js +36 -2
- package/dist/src/symbols/python-module-scope.js.map +1 -1
- package/dist/src/symbols/python-output-symbol.d.ts +11 -0
- package/dist/src/symbols/python-output-symbol.d.ts.map +1 -1
- package/dist/src/symbols/python-output-symbol.js +26 -2
- package/dist/src/symbols/python-output-symbol.js.map +1 -1
- package/dist/src/symbols/reference.d.ts +8 -1
- package/dist/src/symbols/reference.d.ts.map +1 -1
- package/dist/src/symbols/reference.js +4 -2
- package/dist/src/symbols/reference.js.map +1 -1
- package/dist/test/dataclassdeclarations.test.js +5 -2
- package/dist/test/dataclassdeclarations.test.js.map +1 -1
- package/dist/test/externals.test.js +8 -2
- package/dist/test/externals.test.js.map +1 -1
- package/dist/test/functiondeclaration.test.js +6 -3
- package/dist/test/functiondeclaration.test.js.map +1 -1
- package/dist/test/imports.test.js +3 -3
- package/dist/test/imports.test.js.map +1 -1
- package/dist/test/references.test.js +1 -1
- package/dist/test/references.test.js.map +1 -1
- package/dist/test/sourcefiles.test.js +26 -26
- package/dist/test/sourcefiles.test.js.map +1 -1
- package/dist/test/type-checking-imports.test.d.ts +2 -0
- package/dist/test/type-checking-imports.test.d.ts.map +1 -0
- package/dist/test/type-checking-imports.test.js +437 -0
- package/dist/test/type-checking-imports.test.js.map +1 -0
- package/dist/test/uniontypeexpression.test.js +4 -1
- package/dist/test/uniontypeexpression.test.js.map +1 -1
- package/dist/test/variables.test.js +4 -1
- package/dist/test/variables.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -4
- package/src/components/CallSignature.tsx +6 -2
- package/src/components/ImportStatement.tsx +51 -4
- package/src/components/Reference.tsx +3 -1
- package/src/components/SourceFile.tsx +44 -8
- package/src/components/TypeRefContext.tsx +36 -0
- package/src/components/TypeReference.tsx +15 -7
- package/src/components/VariableDeclaration.tsx +5 -1
- package/src/components/index.ts +1 -1
- package/src/context/index.ts +1 -0
- package/src/context/type-ref-context.tsx +16 -0
- package/src/symbols/python-module-scope.ts +55 -2
- package/src/symbols/python-output-symbol.ts +32 -1
- package/src/symbols/reference.tsx +10 -0
- package/temp/api.json +441 -336
- package/test/dataclassdeclarations.test.tsx +8 -2
- package/test/externals.test.tsx +8 -2
- package/test/functiondeclaration.test.tsx +6 -3
- package/test/imports.test.tsx +6 -6
- package/test/references.test.tsx +1 -1
- package/test/sourcefiles.test.tsx +13 -13
- package/test/type-checking-imports.test.tsx +363 -0
- package/test/uniontypeexpression.test.tsx +4 -1
- package/test/variables.test.tsx +4 -1
- package/vitest.config.ts +8 -0
|
@@ -0,0 +1,482 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { d } from "@alloy-js/core/testing";
|
|
3
|
+
import { describe, expect, it } from "vitest";
|
|
4
|
+
import * as py from "../src/index.js";
|
|
5
|
+
import { toSourceText } from "./utils.js";
|
|
6
|
+
describe("Call Signature Parameters", () => {
|
|
7
|
+
it("renders simple function parameters", () => {
|
|
8
|
+
const result = toSourceText([_$createComponent(py.CallSignatureParameters, {
|
|
9
|
+
parameters: ["a", "b"]
|
|
10
|
+
}, {
|
|
11
|
+
fileName: import.meta.url,
|
|
12
|
+
lineNumber: 9,
|
|
13
|
+
columnNumber: 7
|
|
14
|
+
})]);
|
|
15
|
+
expect(result).toRenderTo(d`
|
|
16
|
+
a, b
|
|
17
|
+
`);
|
|
18
|
+
});
|
|
19
|
+
it("renders ParameterDescriptor parameters", () => {
|
|
20
|
+
const result = toSourceText([_$createComponent(py.CallSignatureParameters, {
|
|
21
|
+
parameters: [{
|
|
22
|
+
name: "a"
|
|
23
|
+
}, {
|
|
24
|
+
name: "b"
|
|
25
|
+
}]
|
|
26
|
+
}, {
|
|
27
|
+
fileName: import.meta.url,
|
|
28
|
+
lineNumber: 17,
|
|
29
|
+
columnNumber: 7
|
|
30
|
+
})]);
|
|
31
|
+
expect(result).toRenderTo(d`
|
|
32
|
+
a, b
|
|
33
|
+
`);
|
|
34
|
+
});
|
|
35
|
+
it("renders ParameterDescriptor parameters with types", () => {
|
|
36
|
+
const result = toSourceText([_$createComponent(py.CallSignatureParameters, {
|
|
37
|
+
parameters: [{
|
|
38
|
+
name: "a",
|
|
39
|
+
type: "int"
|
|
40
|
+
}, {
|
|
41
|
+
name: "b",
|
|
42
|
+
type: "str"
|
|
43
|
+
}]
|
|
44
|
+
}, {
|
|
45
|
+
fileName: import.meta.url,
|
|
46
|
+
lineNumber: 27,
|
|
47
|
+
columnNumber: 7
|
|
48
|
+
})]);
|
|
49
|
+
expect(result).toRenderTo(d`
|
|
50
|
+
a: int, b: str
|
|
51
|
+
`);
|
|
52
|
+
});
|
|
53
|
+
it("renders optional ParameterDescriptor parameters with types", () => {
|
|
54
|
+
const result = toSourceText([_$createComponent(py.CallSignatureParameters, {
|
|
55
|
+
parameters: [{
|
|
56
|
+
name: "a",
|
|
57
|
+
type: "int",
|
|
58
|
+
default: null
|
|
59
|
+
}, {
|
|
60
|
+
name: "b",
|
|
61
|
+
type: "str",
|
|
62
|
+
default: null
|
|
63
|
+
}]
|
|
64
|
+
}, {
|
|
65
|
+
fileName: import.meta.url,
|
|
66
|
+
lineNumber: 46,
|
|
67
|
+
columnNumber: 7
|
|
68
|
+
})]);
|
|
69
|
+
expect(result).toRenderTo(d`
|
|
70
|
+
a: int = None, b: str = None
|
|
71
|
+
`);
|
|
72
|
+
});
|
|
73
|
+
it("renders optional ParameterDescriptor parameters default", () => {
|
|
74
|
+
const result = toSourceText([_$createComponent(py.CallSignatureParameters, {
|
|
75
|
+
parameters: [{
|
|
76
|
+
name: "a",
|
|
77
|
+
default: 5
|
|
78
|
+
}, {
|
|
79
|
+
name: "b",
|
|
80
|
+
default: "hello"
|
|
81
|
+
}]
|
|
82
|
+
}, {
|
|
83
|
+
fileName: import.meta.url,
|
|
84
|
+
lineNumber: 67,
|
|
85
|
+
columnNumber: 7
|
|
86
|
+
})]);
|
|
87
|
+
expect(result).toRenderTo(d`
|
|
88
|
+
a=5, b="hello"
|
|
89
|
+
`);
|
|
90
|
+
});
|
|
91
|
+
it("renders optional ParameterDescriptor parameters with types and default", () => {
|
|
92
|
+
const result = toSourceText([_$createComponent(py.CallSignatureParameters, {
|
|
93
|
+
parameters: [{
|
|
94
|
+
name: "a",
|
|
95
|
+
type: "int",
|
|
96
|
+
default: 5
|
|
97
|
+
}, {
|
|
98
|
+
name: "b",
|
|
99
|
+
type: "str",
|
|
100
|
+
default: "hello"
|
|
101
|
+
}]
|
|
102
|
+
}, {
|
|
103
|
+
fileName: import.meta.url,
|
|
104
|
+
lineNumber: 80,
|
|
105
|
+
columnNumber: 7
|
|
106
|
+
})]);
|
|
107
|
+
expect(result).toRenderTo(d`
|
|
108
|
+
a: int = 5, b: str = "hello"
|
|
109
|
+
`);
|
|
110
|
+
});
|
|
111
|
+
it("renders keyword-only parameters with * marker", () => {
|
|
112
|
+
const result = toSourceText([_$createComponent(py.CallSignatureParameters, {
|
|
113
|
+
parameters: [{
|
|
114
|
+
name: "a",
|
|
115
|
+
type: "str"
|
|
116
|
+
}, "*", {
|
|
117
|
+
name: "b",
|
|
118
|
+
type: "int",
|
|
119
|
+
default: 10
|
|
120
|
+
}, {
|
|
121
|
+
name: "c",
|
|
122
|
+
type: "bool",
|
|
123
|
+
default: true
|
|
124
|
+
}]
|
|
125
|
+
}, {
|
|
126
|
+
fileName: import.meta.url,
|
|
127
|
+
lineNumber: 101,
|
|
128
|
+
columnNumber: 7
|
|
129
|
+
})]);
|
|
130
|
+
expect(result).toRenderTo(d`
|
|
131
|
+
a: str, *, b: int = 10, c: bool = True
|
|
132
|
+
`);
|
|
133
|
+
});
|
|
134
|
+
it("renders only keyword-only parameters with * marker at start", () => {
|
|
135
|
+
const result = toSourceText([_$createComponent(py.CallSignatureParameters, {
|
|
136
|
+
parameters: ["*", {
|
|
137
|
+
name: "a",
|
|
138
|
+
type: "str",
|
|
139
|
+
default: "hello"
|
|
140
|
+
}, {
|
|
141
|
+
name: "b",
|
|
142
|
+
type: "int",
|
|
143
|
+
default: 42
|
|
144
|
+
}]
|
|
145
|
+
}, {
|
|
146
|
+
fileName: import.meta.url,
|
|
147
|
+
lineNumber: 116,
|
|
148
|
+
columnNumber: 7
|
|
149
|
+
})]);
|
|
150
|
+
expect(result).toRenderTo(d`
|
|
151
|
+
*, a: str = "hello", b: int = 42
|
|
152
|
+
`);
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
describe("Call Signature", () => {
|
|
156
|
+
it("renders a call signature with strings", () => {
|
|
157
|
+
const result = toSourceText([_$createComponent(py.CallSignature, {
|
|
158
|
+
parameters: ["a", "b"]
|
|
159
|
+
}, {
|
|
160
|
+
fileName: import.meta.url,
|
|
161
|
+
lineNumber: 132,
|
|
162
|
+
columnNumber: 34
|
|
163
|
+
})]);
|
|
164
|
+
expect(result).toRenderTo(d`
|
|
165
|
+
(a, b)
|
|
166
|
+
`);
|
|
167
|
+
});
|
|
168
|
+
it("renders a call signature with parameter descriptors", () => {
|
|
169
|
+
const result = toSourceText([_$createComponent(py.CallSignature, {
|
|
170
|
+
parameters: [{
|
|
171
|
+
name: "a"
|
|
172
|
+
}, {
|
|
173
|
+
name: "b"
|
|
174
|
+
}]
|
|
175
|
+
}, {
|
|
176
|
+
fileName: import.meta.url,
|
|
177
|
+
lineNumber: 139,
|
|
178
|
+
columnNumber: 7
|
|
179
|
+
})]);
|
|
180
|
+
expect(result).toRenderTo(d`
|
|
181
|
+
(a, b)
|
|
182
|
+
`);
|
|
183
|
+
});
|
|
184
|
+
it("renders a call signature with mixed strings and parameter descriptors", () => {
|
|
185
|
+
const result = toSourceText([_$createComponent(py.CallSignature, {
|
|
186
|
+
parameters: ["a", {
|
|
187
|
+
name: "b"
|
|
188
|
+
}]
|
|
189
|
+
}, {
|
|
190
|
+
fileName: import.meta.url,
|
|
191
|
+
lineNumber: 147,
|
|
192
|
+
columnNumber: 7
|
|
193
|
+
})]);
|
|
194
|
+
expect(result).toRenderTo(d`
|
|
195
|
+
(a, b)
|
|
196
|
+
`);
|
|
197
|
+
});
|
|
198
|
+
it("renders a simple call signature with args and kwargs", () => {
|
|
199
|
+
const result = toSourceText([_$createComponent(py.CallSignature, {
|
|
200
|
+
parameters: [{
|
|
201
|
+
name: "a"
|
|
202
|
+
}, {
|
|
203
|
+
name: "b"
|
|
204
|
+
}],
|
|
205
|
+
args: true,
|
|
206
|
+
kwargs: true
|
|
207
|
+
}, {
|
|
208
|
+
fileName: import.meta.url,
|
|
209
|
+
lineNumber: 155,
|
|
210
|
+
columnNumber: 7
|
|
211
|
+
})]);
|
|
212
|
+
expect(result).toRenderTo(d`
|
|
213
|
+
(a, b, *args, **kwargs)
|
|
214
|
+
`);
|
|
215
|
+
});
|
|
216
|
+
it("renders a simple call signature with type parameters", () => {
|
|
217
|
+
const result = toSourceText([_$createComponent(py.CallSignature, {
|
|
218
|
+
parameters: [{
|
|
219
|
+
name: "a"
|
|
220
|
+
}, {
|
|
221
|
+
name: "b"
|
|
222
|
+
}],
|
|
223
|
+
typeParameters: ["T", "U"]
|
|
224
|
+
}, {
|
|
225
|
+
fileName: import.meta.url,
|
|
226
|
+
lineNumber: 167,
|
|
227
|
+
columnNumber: 7
|
|
228
|
+
})]);
|
|
229
|
+
expect(result).toRenderTo(d`
|
|
230
|
+
[T, U](a, b)
|
|
231
|
+
`);
|
|
232
|
+
});
|
|
233
|
+
it("renders a simple call signature with return type", () => {
|
|
234
|
+
const result = toSourceText([_$createComponent(py.CallSignature, {
|
|
235
|
+
parameters: [{
|
|
236
|
+
name: "a"
|
|
237
|
+
}, {
|
|
238
|
+
name: "b"
|
|
239
|
+
}],
|
|
240
|
+
returnType: "int"
|
|
241
|
+
}, {
|
|
242
|
+
fileName: import.meta.url,
|
|
243
|
+
lineNumber: 178,
|
|
244
|
+
columnNumber: 7
|
|
245
|
+
})]);
|
|
246
|
+
expect(result).toRenderTo(d`
|
|
247
|
+
(a, b) -> int
|
|
248
|
+
`);
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
describe("Call Signature - Parameter Descriptors", () => {
|
|
252
|
+
it("renders a call signature with parameter descriptors", () => {
|
|
253
|
+
const result = toSourceText([_$createComponent(py.CallSignature, {
|
|
254
|
+
parameters: [{
|
|
255
|
+
name: "a",
|
|
256
|
+
type: "int"
|
|
257
|
+
}, {
|
|
258
|
+
name: "b",
|
|
259
|
+
type: "str"
|
|
260
|
+
}]
|
|
261
|
+
}, {
|
|
262
|
+
fileName: import.meta.url,
|
|
263
|
+
lineNumber: 192,
|
|
264
|
+
columnNumber: 7
|
|
265
|
+
})]);
|
|
266
|
+
expect(result).toRenderTo(d`
|
|
267
|
+
(a: int, b: str)
|
|
268
|
+
`);
|
|
269
|
+
});
|
|
270
|
+
it("renders a call signature with parameter descriptors, args and kwargs", () => {
|
|
271
|
+
const result = toSourceText([_$createComponent(py.CallSignature, {
|
|
272
|
+
parameters: [{
|
|
273
|
+
name: "a",
|
|
274
|
+
type: "int"
|
|
275
|
+
}, {
|
|
276
|
+
name: "b",
|
|
277
|
+
type: "str"
|
|
278
|
+
}],
|
|
279
|
+
args: true,
|
|
280
|
+
kwargs: true
|
|
281
|
+
}, {
|
|
282
|
+
fileName: import.meta.url,
|
|
283
|
+
lineNumber: 211,
|
|
284
|
+
columnNumber: 7
|
|
285
|
+
})]);
|
|
286
|
+
expect(result).toRenderTo(d`
|
|
287
|
+
(a: int, b: str, *args, **kwargs)
|
|
288
|
+
`);
|
|
289
|
+
});
|
|
290
|
+
it("renders a call signature with parameter descriptors and return type", () => {
|
|
291
|
+
const result = toSourceText([_$createComponent(py.CallSignature, {
|
|
292
|
+
parameters: [{
|
|
293
|
+
name: "a",
|
|
294
|
+
type: "int"
|
|
295
|
+
}, {
|
|
296
|
+
name: "b",
|
|
297
|
+
type: "str"
|
|
298
|
+
}],
|
|
299
|
+
returnType: "int"
|
|
300
|
+
}, {
|
|
301
|
+
fileName: import.meta.url,
|
|
302
|
+
lineNumber: 232,
|
|
303
|
+
columnNumber: 7
|
|
304
|
+
})]);
|
|
305
|
+
expect(result).toRenderTo(d`
|
|
306
|
+
(a: int, b: str) -> int
|
|
307
|
+
`);
|
|
308
|
+
});
|
|
309
|
+
it("renders a call signature with parameter descriptors for a class function", () => {
|
|
310
|
+
const result = toSourceText([_$createComponent(py.CallSignature, {
|
|
311
|
+
parameters: [{
|
|
312
|
+
name: "a",
|
|
313
|
+
type: "int"
|
|
314
|
+
}, {
|
|
315
|
+
name: "b",
|
|
316
|
+
type: "str"
|
|
317
|
+
}]
|
|
318
|
+
}, {
|
|
319
|
+
fileName: import.meta.url,
|
|
320
|
+
lineNumber: 252,
|
|
321
|
+
columnNumber: 7
|
|
322
|
+
})]);
|
|
323
|
+
expect(result).toRenderTo(d`
|
|
324
|
+
(a: int, b: str)
|
|
325
|
+
`);
|
|
326
|
+
});
|
|
327
|
+
it("renders a call signature with all", () => {
|
|
328
|
+
const result = toSourceText([_$createComponent(py.CallSignature, {
|
|
329
|
+
parameters: [{
|
|
330
|
+
name: "a",
|
|
331
|
+
type: "int"
|
|
332
|
+
}, {
|
|
333
|
+
name: "b",
|
|
334
|
+
type: "str"
|
|
335
|
+
}],
|
|
336
|
+
args: true,
|
|
337
|
+
kwargs: true,
|
|
338
|
+
returnType: "int"
|
|
339
|
+
}, {
|
|
340
|
+
fileName: import.meta.url,
|
|
341
|
+
lineNumber: 271,
|
|
342
|
+
columnNumber: 7
|
|
343
|
+
})]);
|
|
344
|
+
expect(result).toRenderTo(d`
|
|
345
|
+
(a: int, b: str, *args, **kwargs) -> int
|
|
346
|
+
`);
|
|
347
|
+
});
|
|
348
|
+
it("renders a more complex call signature with parameter descriptors", () => {
|
|
349
|
+
const result = toSourceText([_$createComponent(py.CallSignature, {
|
|
350
|
+
typeParameters: ["T", "U"],
|
|
351
|
+
parameters: [{
|
|
352
|
+
name: "a",
|
|
353
|
+
type: "int"
|
|
354
|
+
}, {
|
|
355
|
+
name: "b",
|
|
356
|
+
type: "str",
|
|
357
|
+
default: "default_value"
|
|
358
|
+
}],
|
|
359
|
+
returnType: "int"
|
|
360
|
+
}, {
|
|
361
|
+
fileName: import.meta.url,
|
|
362
|
+
lineNumber: 293,
|
|
363
|
+
columnNumber: 7
|
|
364
|
+
})]);
|
|
365
|
+
expect(result).toRenderTo(d`
|
|
366
|
+
[T, U](a: int, b: str = "default_value") -> int
|
|
367
|
+
`);
|
|
368
|
+
});
|
|
369
|
+
it("renders a call signature with keyword-only parameters using * marker", () => {
|
|
370
|
+
const result = toSourceText([_$createComponent(py.CallSignature, {
|
|
371
|
+
parameters: [{
|
|
372
|
+
name: "id",
|
|
373
|
+
type: "str"
|
|
374
|
+
}, "*", {
|
|
375
|
+
name: "locale",
|
|
376
|
+
type: "str",
|
|
377
|
+
default: "en-US"
|
|
378
|
+
}, {
|
|
379
|
+
name: "debug",
|
|
380
|
+
type: "bool",
|
|
381
|
+
default: false
|
|
382
|
+
}],
|
|
383
|
+
returnType: "str"
|
|
384
|
+
}, {
|
|
385
|
+
fileName: import.meta.url,
|
|
386
|
+
lineNumber: 315,
|
|
387
|
+
columnNumber: 7
|
|
388
|
+
})]);
|
|
389
|
+
expect(result).toRenderTo(d`
|
|
390
|
+
(id: str, *, locale: str = "en-US", debug: bool = False) -> str
|
|
391
|
+
`);
|
|
392
|
+
});
|
|
393
|
+
it("renders a call signature with only keyword-only parameters", () => {
|
|
394
|
+
const result = toSourceText([_$createComponent(py.CallSignature, {
|
|
395
|
+
parameters: ["*", {
|
|
396
|
+
name: "name",
|
|
397
|
+
type: "str",
|
|
398
|
+
default: "alice"
|
|
399
|
+
}, {
|
|
400
|
+
name: "age",
|
|
401
|
+
type: "int",
|
|
402
|
+
default: 30
|
|
403
|
+
}],
|
|
404
|
+
returnType: "None"
|
|
405
|
+
}, {
|
|
406
|
+
fileName: import.meta.url,
|
|
407
|
+
lineNumber: 331,
|
|
408
|
+
columnNumber: 7
|
|
409
|
+
})]);
|
|
410
|
+
expect(result).toRenderTo(d`
|
|
411
|
+
(*, name: str = "alice", age: int = 30) -> None
|
|
412
|
+
`);
|
|
413
|
+
});
|
|
414
|
+
it("renders a call signature with positional, keyword-only, and *args/**kwargs", () => {
|
|
415
|
+
const result = toSourceText([_$createComponent(py.CallSignature, {
|
|
416
|
+
parameters: [{
|
|
417
|
+
name: "a",
|
|
418
|
+
type: "int"
|
|
419
|
+
}, "*", {
|
|
420
|
+
name: "b",
|
|
421
|
+
type: "str",
|
|
422
|
+
default: "hello"
|
|
423
|
+
}],
|
|
424
|
+
args: true,
|
|
425
|
+
kwargs: true,
|
|
426
|
+
returnType: "None"
|
|
427
|
+
}, {
|
|
428
|
+
fileName: import.meta.url,
|
|
429
|
+
lineNumber: 346,
|
|
430
|
+
columnNumber: 7
|
|
431
|
+
})]);
|
|
432
|
+
expect(result).toRenderTo(d`
|
|
433
|
+
(a: int, *, b: str = "hello", *args, **kwargs) -> None
|
|
434
|
+
`);
|
|
435
|
+
});
|
|
436
|
+
it("renders a call signature with positional-only parameters using / marker", () => {
|
|
437
|
+
const result = toSourceText([_$createComponent(py.CallSignature, {
|
|
438
|
+
parameters: [{
|
|
439
|
+
name: "a",
|
|
440
|
+
type: "int"
|
|
441
|
+
}, {
|
|
442
|
+
name: "b",
|
|
443
|
+
type: "str"
|
|
444
|
+
}, "/", {
|
|
445
|
+
name: "c",
|
|
446
|
+
type: "bool"
|
|
447
|
+
}],
|
|
448
|
+
returnType: "None"
|
|
449
|
+
}, {
|
|
450
|
+
fileName: import.meta.url,
|
|
451
|
+
lineNumber: 363,
|
|
452
|
+
columnNumber: 7
|
|
453
|
+
})]);
|
|
454
|
+
expect(result).toRenderTo(d`
|
|
455
|
+
(a: int, b: str, /, c: bool) -> None
|
|
456
|
+
`);
|
|
457
|
+
});
|
|
458
|
+
it("renders a call signature with positional-only, regular, and keyword-only parameters", () => {
|
|
459
|
+
const result = toSourceText([_$createComponent(py.CallSignature, {
|
|
460
|
+
parameters: [{
|
|
461
|
+
name: "a",
|
|
462
|
+
type: "int"
|
|
463
|
+
}, "/", {
|
|
464
|
+
name: "b",
|
|
465
|
+
type: "str"
|
|
466
|
+
}, "*", {
|
|
467
|
+
name: "c",
|
|
468
|
+
type: "bool",
|
|
469
|
+
default: true
|
|
470
|
+
}],
|
|
471
|
+
returnType: "None"
|
|
472
|
+
}, {
|
|
473
|
+
fileName: import.meta.url,
|
|
474
|
+
lineNumber: 379,
|
|
475
|
+
columnNumber: 7
|
|
476
|
+
})]);
|
|
477
|
+
expect(result).toRenderTo(d`
|
|
478
|
+
(a: int, /, b: str, *, c: bool = True) -> None
|
|
479
|
+
`);
|
|
480
|
+
});
|
|
481
|
+
});
|
|
482
|
+
//# sourceMappingURL=callsignatures.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["d","describe","expect","it","py","toSourceText","result","_$createComponent","CallSignatureParameters","parameters","fileName","import","meta","url","lineNumber","columnNumber","toRenderTo","name","type","default","CallSignature","args","kwargs","typeParameters","returnType"],"sources":["../../../test/callsignatures.test.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,CAAC,QAAQ,wBAAwB;AAC1C,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,OAAO,KAAKC,EAAE,MAAM,iBAAiB;AACrC,SAASC,YAAY;AAErBJ,QAAQ,CAAC,2BAA2B,EAA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-runtime";
|
|
2
|
+
import { d } from "@alloy-js/core/testing";
|
|
3
|
+
import { describe, expect, it } from "vitest";
|
|
4
|
+
import * as py from "../src/index.js";
|
|
5
|
+
import { toSourceText } from "./utils.js";
|
|
6
|
+
describe("ClassMethodDeclaration", () => {
|
|
7
|
+
it("renders async class method", () => {
|
|
8
|
+
const decl = _$createComponent(py.StatementList, {
|
|
9
|
+
get children() {
|
|
10
|
+
return _$createComponent(py.ClassDeclaration, {
|
|
11
|
+
name: "MyClass",
|
|
12
|
+
get children() {
|
|
13
|
+
return _$createComponent(py.StatementList, {
|
|
14
|
+
get children() {
|
|
15
|
+
return _$createComponent(py.ClassMethodDeclaration, {
|
|
16
|
+
async: true,
|
|
17
|
+
name: "create",
|
|
18
|
+
returnType: "MyClass",
|
|
19
|
+
children: "return cls()"
|
|
20
|
+
}, {
|
|
21
|
+
fileName: import.meta.url,
|
|
22
|
+
lineNumber: 12,
|
|
23
|
+
columnNumber: 13
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}, {
|
|
27
|
+
fileName: import.meta.url,
|
|
28
|
+
lineNumber: 11,
|
|
29
|
+
columnNumber: 11
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}, {
|
|
33
|
+
fileName: import.meta.url,
|
|
34
|
+
lineNumber: 10,
|
|
35
|
+
columnNumber: 9
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}, {
|
|
39
|
+
fileName: import.meta.url,
|
|
40
|
+
lineNumber: 9,
|
|
41
|
+
columnNumber: 7
|
|
42
|
+
});
|
|
43
|
+
expect(toSourceText([decl])).toBe(d`
|
|
44
|
+
class MyClass:
|
|
45
|
+
@classmethod
|
|
46
|
+
async def create(cls) -> MyClass:
|
|
47
|
+
return cls()
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
`);
|
|
51
|
+
});
|
|
52
|
+
it("renders class method with parameters", () => {
|
|
53
|
+
const parameters = [{
|
|
54
|
+
name: "x",
|
|
55
|
+
type: "int"
|
|
56
|
+
}];
|
|
57
|
+
const decl = _$createComponent(py.ClassDeclaration, {
|
|
58
|
+
name: "MyClass",
|
|
59
|
+
get children() {
|
|
60
|
+
return _$createComponent(py.ClassMethodDeclaration, {
|
|
61
|
+
name: "foo",
|
|
62
|
+
parameters: parameters,
|
|
63
|
+
children: "self.attribute = \"value\""
|
|
64
|
+
}, {
|
|
65
|
+
fileName: import.meta.url,
|
|
66
|
+
lineNumber: 38,
|
|
67
|
+
columnNumber: 9
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}, {
|
|
71
|
+
fileName: import.meta.url,
|
|
72
|
+
lineNumber: 37,
|
|
73
|
+
columnNumber: 7
|
|
74
|
+
});
|
|
75
|
+
expect(toSourceText([decl])).toBe(d`
|
|
76
|
+
class MyClass:
|
|
77
|
+
@classmethod
|
|
78
|
+
def foo(cls, x: int):
|
|
79
|
+
self.attribute = "value"
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
`);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
//# sourceMappingURL=class-method-declaration.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["d","describe","expect","it","py","toSourceText","decl","_$createComponent","StatementList","children","ClassDeclaration","name","ClassMethodDeclaration","async","returnType","fileName","import","meta","url","lineNumber","columnNumber","toBe","parameters","type"],"sources":["../../../test/class-method-declaration.test.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,CAAC,QAAQ,wBAAwB;AAC1C,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,OAAO,KAAKC,EAAE,MAAM,iBAAiB;AACrC,SAASC,YAAY,QAAQ,YAAY;AAEzCJ,QAAQ,CAAC,wBAAwB,EAAE,MAAM;EACvCE,EAAE,CAAC,4BAA4B,EAAE,MAAM;IACrC,MAAMG,IAAI,GAAAC,iBAAA,CACPH,EAAE,CAACI,aAAa;MAAA,IAAAC,SAAA;QAAA,OAAA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