@alloy-js/python 0.2.0-dev.3 → 0.2.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/src/builtins/python.d.ts +3 -0
- package/dist/src/builtins/python.d.ts.map +1 -1
- package/dist/src/builtins/python.js +6 -0
- package/dist/src/builtins/python.js.map +1 -1
- package/dist/src/components/Atom.d.ts +1 -0
- package/dist/src/components/Atom.d.ts.map +1 -1
- package/dist/src/components/Atom.js +3 -0
- package/dist/src/components/Atom.js.map +1 -1
- package/dist/src/components/CallSignature.d.ts +4 -15
- package/dist/src/components/CallSignature.d.ts.map +1 -1
- package/dist/src/components/CallSignature.js +13 -67
- package/dist/src/components/CallSignature.js.map +1 -1
- package/dist/src/components/ClassMethodDeclaration.d.ts +22 -0
- package/dist/src/components/ClassMethodDeclaration.d.ts.map +1 -0
- package/dist/src/components/ClassMethodDeclaration.js +32 -0
- package/dist/src/components/ClassMethodDeclaration.js.map +1 -0
- package/dist/src/components/ConstructorDeclaration.d.ts +21 -0
- package/dist/src/components/ConstructorDeclaration.d.ts.map +1 -0
- package/dist/src/components/ConstructorDeclaration.js +35 -0
- package/dist/src/components/ConstructorDeclaration.js.map +1 -0
- package/dist/src/components/DunderMethodDeclaration.d.ts +21 -0
- package/dist/src/components/DunderMethodDeclaration.d.ts.map +1 -0
- package/dist/src/components/DunderMethodDeclaration.js +29 -0
- package/dist/src/components/DunderMethodDeclaration.js.map +1 -0
- package/dist/src/components/EnumDeclaration.d.ts +11 -32
- package/dist/src/components/EnumDeclaration.d.ts.map +1 -1
- package/dist/src/components/EnumDeclaration.js +10 -48
- package/dist/src/components/EnumDeclaration.js.map +1 -1
- package/dist/src/components/EnumMember.js +3 -3
- package/dist/src/components/EnumMember.js.map +1 -1
- package/dist/src/components/FunctionBase.d.ts +48 -0
- package/dist/src/components/FunctionBase.d.ts.map +1 -0
- package/dist/src/components/FunctionBase.js +91 -0
- package/dist/src/components/FunctionBase.js.map +1 -0
- package/dist/src/components/FunctionDeclaration.d.ts +11 -31
- package/dist/src/components/FunctionDeclaration.d.ts.map +1 -1
- package/dist/src/components/FunctionDeclaration.js +22 -79
- package/dist/src/components/FunctionDeclaration.js.map +1 -1
- package/dist/src/components/MethodBase.d.ts +29 -0
- package/dist/src/components/MethodBase.d.ts.map +1 -0
- package/dist/src/components/MethodBase.js +32 -0
- package/dist/src/components/MethodBase.js.map +1 -0
- package/dist/src/components/MethodDeclaration.d.ts +22 -0
- package/dist/src/components/MethodDeclaration.d.ts.map +1 -0
- package/dist/src/components/MethodDeclaration.js +34 -0
- package/dist/src/components/MethodDeclaration.js.map +1 -0
- package/dist/src/components/PropertyDeclaration.d.ts +71 -0
- package/dist/src/components/PropertyDeclaration.d.ts.map +1 -0
- package/dist/src/components/PropertyDeclaration.js +227 -0
- package/dist/src/components/PropertyDeclaration.js.map +1 -0
- package/dist/src/components/PyDoc.d.ts +107 -42
- package/dist/src/components/PyDoc.d.ts.map +1 -1
- package/dist/src/components/PyDoc.js +845 -181
- package/dist/src/components/PyDoc.js.map +1 -1
- package/dist/src/components/SourceFile.d.ts +24 -0
- package/dist/src/components/SourceFile.d.ts.map +1 -1
- package/dist/src/components/SourceFile.js +28 -1
- package/dist/src/components/SourceFile.js.map +1 -1
- package/dist/src/components/StaticMethodDeclaration.d.ts +22 -0
- package/dist/src/components/StaticMethodDeclaration.d.ts.map +1 -0
- package/dist/src/components/StaticMethodDeclaration.js +32 -0
- package/dist/src/components/StaticMethodDeclaration.js.map +1 -0
- package/dist/src/components/TypeArguments.d.ts +9 -0
- package/dist/src/components/TypeArguments.d.ts.map +1 -0
- package/dist/src/components/TypeArguments.js +18 -0
- package/dist/src/components/TypeArguments.js.map +1 -0
- package/dist/src/components/TypeReference.d.ts +14 -0
- package/dist/src/components/TypeReference.d.ts.map +1 -0
- package/dist/src/components/TypeReference.js +29 -0
- package/dist/src/components/TypeReference.js.map +1 -0
- package/dist/src/components/UnionTypeExpression.d.ts +1 -2
- package/dist/src/components/UnionTypeExpression.d.ts.map +1 -1
- package/dist/src/components/UnionTypeExpression.js +3 -11
- package/dist/src/components/UnionTypeExpression.js.map +1 -1
- package/dist/src/components/VariableDeclaration.d.ts.map +1 -1
- package/dist/src/components/VariableDeclaration.js +3 -3
- package/dist/src/components/VariableDeclaration.js.map +1 -1
- package/dist/src/components/index.d.ts +10 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +9 -0
- package/dist/src/components/index.js.map +1 -1
- package/dist/src/parameter-descriptor.d.ts +1 -4
- package/dist/src/parameter-descriptor.d.ts.map +1 -1
- package/dist/src/parameter-descriptor.js +7 -1
- package/dist/src/parameter-descriptor.js.map +1 -1
- package/dist/src/symbol-creation.d.ts +4 -0
- package/dist/src/symbol-creation.d.ts.map +1 -1
- package/dist/src/symbol-creation.js +12 -0
- package/dist/src/symbol-creation.js.map +1 -1
- package/dist/src/symbols/factories.d.ts +15 -0
- package/dist/src/symbols/factories.d.ts.map +1 -0
- package/dist/src/symbols/factories.js +28 -0
- package/dist/src/symbols/factories.js.map +1 -0
- package/dist/src/symbols/index.d.ts +1 -0
- package/dist/src/symbols/index.d.ts.map +1 -1
- package/dist/src/symbols/index.js +1 -0
- package/dist/src/symbols/index.js.map +1 -1
- package/dist/src/symbols/reference.d.ts +1 -1
- package/dist/src/symbols/reference.d.ts.map +1 -1
- package/dist/src/symbols/reference.js +1 -1
- package/dist/src/symbols/reference.js.map +1 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +1 -1
- package/dist/src/utils.js.map +1 -1
- package/dist/test/callsignatures.test.js +42 -64
- package/dist/test/callsignatures.test.js.map +1 -1
- package/dist/test/class-method-declaration.test.d.ts +2 -0
- package/dist/test/class-method-declaration.test.d.ts.map +1 -0
- package/dist/test/class-method-declaration.test.js +61 -0
- package/dist/test/class-method-declaration.test.js.map +1 -0
- package/dist/test/classdeclarations.test.js +6 -8
- package/dist/test/classdeclarations.test.js.map +1 -1
- package/dist/test/constructordeclaration.test.d.ts +2 -0
- package/dist/test/constructordeclaration.test.d.ts.map +1 -0
- package/dist/test/constructordeclaration.test.js +58 -0
- package/dist/test/constructordeclaration.test.js.map +1 -0
- package/dist/test/dundermethoddeclaration.test.d.ts +2 -0
- package/dist/test/dundermethoddeclaration.test.d.ts.map +1 -0
- package/dist/test/dundermethoddeclaration.test.js +65 -0
- package/dist/test/dundermethoddeclaration.test.js.map +1 -0
- package/dist/test/enums.test.js +14 -16
- package/dist/test/enums.test.js.map +1 -1
- package/dist/test/externals.test.js +2 -4
- package/dist/test/externals.test.js.map +1 -1
- package/dist/test/factories.test.d.ts +2 -0
- package/dist/test/factories.test.d.ts.map +1 -0
- package/dist/test/factories.test.js +78 -0
- package/dist/test/factories.test.js.map +1 -0
- package/dist/test/functiondeclaration.test.js +213 -59
- package/dist/test/functiondeclaration.test.js.map +1 -1
- package/dist/test/memberexpressions.test.js +1 -1
- package/dist/test/memberexpressions.test.js.map +1 -1
- package/dist/test/methoddeclaration.test.d.ts +2 -0
- package/dist/test/methoddeclaration.test.d.ts.map +1 -0
- package/dist/test/methoddeclaration.test.js +239 -0
- package/dist/test/methoddeclaration.test.js.map +1 -0
- package/dist/test/namepolicies.test.js +1 -2
- package/dist/test/namepolicies.test.js.map +1 -1
- package/dist/test/propertydeclaration.test.d.ts +2 -0
- package/dist/test/propertydeclaration.test.d.ts.map +1 -0
- package/dist/test/propertydeclaration.test.js +229 -0
- package/dist/test/propertydeclaration.test.js.map +1 -0
- package/dist/test/pydocs.test.js +926 -126
- package/dist/test/pydocs.test.js.map +1 -1
- package/dist/test/references.test.js +1 -5
- package/dist/test/references.test.js.map +1 -1
- package/dist/test/sourcefiles.test.js +90 -1
- package/dist/test/sourcefiles.test.js.map +1 -1
- package/dist/test/staticmethoddeclaration.test.d.ts +2 -0
- package/dist/test/staticmethoddeclaration.test.d.ts.map +1 -0
- package/dist/test/staticmethoddeclaration.test.js +61 -0
- package/dist/test/staticmethoddeclaration.test.js.map +1 -0
- package/dist/test/typereference.test.d.ts +2 -0
- package/dist/test/typereference.test.d.ts.map +1 -0
- package/dist/test/typereference.test.js +51 -0
- package/dist/test/typereference.test.js.map +1 -0
- package/dist/test/uniontypeexpression.test.js +152 -15
- package/dist/test/uniontypeexpression.test.js.map +1 -1
- package/dist/test/values.test.js +35 -0
- package/dist/test/values.test.js.map +1 -1
- package/dist/test/variables.test.js +28 -19
- package/dist/test/variables.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/builtins/python.ts +7 -0
- package/src/components/Atom.tsx +4 -0
- package/src/components/CallSignature.tsx +17 -69
- package/src/components/ClassMethodDeclaration.tsx +34 -0
- package/src/components/ConstructorDeclaration.tsx +37 -0
- package/src/components/DunderMethodDeclaration.tsx +30 -0
- package/src/components/EnumDeclaration.tsx +16 -44
- package/src/components/EnumMember.tsx +3 -3
- package/src/components/FunctionBase.tsx +88 -0
- package/src/components/FunctionDeclaration.tsx +18 -82
- package/src/components/MethodBase.tsx +53 -0
- package/src/components/MethodDeclaration.tsx +27 -0
- package/src/components/PropertyDeclaration.tsx +264 -0
- package/src/components/PyDoc.tsx +795 -195
- package/src/components/SourceFile.tsx +29 -0
- package/src/components/StaticMethodDeclaration.tsx +34 -0
- package/src/components/TypeArguments.tsx +24 -0
- package/src/components/TypeReference.tsx +33 -0
- package/src/components/UnionTypeExpression.tsx +4 -15
- package/src/components/VariableDeclaration.tsx +1 -3
- package/src/components/index.ts +10 -0
- package/src/parameter-descriptor.ts +6 -5
- package/src/symbol-creation.ts +17 -0
- package/src/symbols/factories.ts +39 -0
- package/src/symbols/index.ts +1 -0
- package/src/symbols/reference.tsx +3 -5
- package/src/utils.ts +0 -2
- package/temp/api.json +5323 -2288
- package/test/callsignatures.test.tsx +102 -74
- package/test/class-method-declaration.test.tsx +53 -0
- package/test/classdeclarations.test.tsx +7 -9
- package/test/constructordeclaration.test.tsx +48 -0
- package/test/dundermethoddeclaration.test.tsx +53 -0
- package/test/enums.test.tsx +14 -16
- package/test/externals.test.tsx +5 -7
- package/test/factories.test.tsx +72 -0
- package/test/functiondeclaration.test.tsx +196 -44
- package/test/memberexpressions.test.tsx +7 -2
- package/test/methoddeclaration.test.tsx +202 -0
- package/test/namepolicies.test.tsx +1 -2
- package/test/propertydeclaration.test.tsx +192 -0
- package/test/pydocs.test.tsx +1093 -129
- package/test/references.test.tsx +1 -1
- package/test/sourcefiles.test.tsx +100 -1
- package/test/staticmethoddeclaration.test.tsx +49 -0
- package/test/typereference.test.tsx +52 -0
- package/test/uniontypeexpression.test.tsx +169 -34
- package/test/values.test.tsx +34 -0
- package/test/variables.test.tsx +27 -16
|
@@ -0,0 +1,65 @@
|
|
|
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("Dunder/Constructor Declarations", () => {
|
|
7
|
+
it("renders dunder methods with parameters", () => {
|
|
8
|
+
const parameters = [{
|
|
9
|
+
name: "x",
|
|
10
|
+
type: "int"
|
|
11
|
+
}];
|
|
12
|
+
const decl = _$createComponent(py.ClassDeclaration, {
|
|
13
|
+
name: "MyClass",
|
|
14
|
+
get children() {
|
|
15
|
+
return _$createComponent(py.StatementList, {
|
|
16
|
+
get children() {
|
|
17
|
+
return [_$createComponent(py.DunderMethodDeclaration, {
|
|
18
|
+
name: "__init__",
|
|
19
|
+
parameters: parameters,
|
|
20
|
+
children: "self.attribute = \"value\""
|
|
21
|
+
}), _$createComponent(py.DunderMethodDeclaration, {
|
|
22
|
+
name: "__repr__",
|
|
23
|
+
parameters: parameters,
|
|
24
|
+
children: "return \"MyClass\""
|
|
25
|
+
})];
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
expect(toSourceText([decl])).toBe(d`
|
|
31
|
+
class MyClass:
|
|
32
|
+
def __init__(self, x: int):
|
|
33
|
+
self.attribute = "value"
|
|
34
|
+
|
|
35
|
+
def __repr__(self, x: int):
|
|
36
|
+
return "MyClass"
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
`);
|
|
40
|
+
});
|
|
41
|
+
it("renders dunder methods __new__", () => {
|
|
42
|
+
const decl = _$createComponent(py.ClassDeclaration, {
|
|
43
|
+
name: "MyClass",
|
|
44
|
+
get children() {
|
|
45
|
+
return _$createComponent(py.StatementList, {
|
|
46
|
+
get children() {
|
|
47
|
+
return _$createComponent(py.ConstructorDeclaration, {
|
|
48
|
+
args: true,
|
|
49
|
+
kwargs: true,
|
|
50
|
+
children: "pass"
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
expect(toSourceText([decl])).toBe(d`
|
|
57
|
+
class MyClass:
|
|
58
|
+
def __new__(cls, *args, **kwargs):
|
|
59
|
+
pass
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
`);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
//# sourceMappingURL=dundermethoddeclaration.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["d","describe","expect","it","py","toSourceText","parameters","name","type","decl","_$createComponent","ClassDeclaration","children","StatementList","DunderMethodDeclaration","toBe","ConstructorDeclaration","args","kwargs"],"sources":["../../test/dundermethoddeclaration.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,iCAAiC,EAAE,MAAM;EAChDE,EAAE,CAAC,wCAAwC,EAAE,MAAM;IACjD,MAAMG,UAAU,GAAG,CAAC;MAAEC,IAAI,EAAE,GAAG;MAAEC,IAAI,EAAE;IAAM,CAAC,CAAC;IAC/C,MAAMC,IAAI,GAAAC,iBAAA,CACPN,EAAE,CAACO,gBAAgB;MAACJ,IAAI;MAAA,IAAAK,SAAA;QAAA,OAAAF,iBAAA,CACtBN,EAAE,CAACS,aAAa;UAAA,IAAAD,SAAA;YAAA,QAAAF,iBAAA,CACdN,EAAE,CAACU,uBAAuB;cAACP,IAAI;cAAYD,UAAU,EAAEA,UAAU;cAAAM,QAAA;YAAA,IAAAF,iBAAA,CAGjEN,EAAE,CAACU,uBAAuB;cAACP,IAAI;cAAYD,UAAU,EAAEA,UAAU;cAAAM,QAAA;YAAA;UAAA;QAAA;MAAA;IAAA,EAKvE;IAEDV,MAAM,CAACG,YAAY,CAAC,CAACI,IAAI,CAAC,CAAC,CAAC,CAACM,IAAI,CAACf,CAAC;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,CAAC;EACJ,CAAC,CAAC;EAEFG,EAAE,CAAC,gCAAgC,EAAE,MAAM;IACzC,MAAMM,IAAI,GAAAC,iBAAA,CACPN,EAAE,CAACO,gBAAgB;MAACJ,IAAI;MAAA,IAAAK,SAAA;QAAA,OAAAF,iBAAA,CACtBN,EAAE,CAACS,aAAa;UAAA,IAAAD,SAAA;YAAA,OAAAF,iBAAA,CACdN,EAAE,CAACY,sBAAsB;cAACC,IAAI;cAACC,MAAM;cAAAN,QAAA;YAAA;UAAA;QAAA;MAAA;IAAA,EAK3C;IAEDV,MAAM,CAACG,YAAY,CAAC,CAACI,IAAI,CAAC,CAAC,CAAC,CAACM,IAAI,CAACf,CAAC;AACvC;AACA;AACA;AACA;AACA;AACA,KAAK,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
package/dist/test/enums.test.js
CHANGED
|
@@ -6,8 +6,8 @@ import { enumModule } from "../src/builtins/python.js";
|
|
|
6
6
|
import * as py from "../src/index.js";
|
|
7
7
|
import { toSourceText } from "./utils.js";
|
|
8
8
|
describe("Python Enum", () => {
|
|
9
|
-
it("
|
|
10
|
-
const result = toSourceText([_$createComponent(py.
|
|
9
|
+
it("class enum with explicit values", () => {
|
|
10
|
+
const result = toSourceText([_$createComponent(py.ClassEnumDeclaration, {
|
|
11
11
|
name: "Color",
|
|
12
12
|
baseType: "IntEnum",
|
|
13
13
|
members: [{
|
|
@@ -35,8 +35,8 @@ describe("Python Enum", () => {
|
|
|
35
35
|
`;
|
|
36
36
|
expect(result).toRenderTo(expected);
|
|
37
37
|
});
|
|
38
|
-
it("
|
|
39
|
-
const result = toSourceText([_$createComponent(py.
|
|
38
|
+
it("class enum with jsValues", () => {
|
|
39
|
+
const result = toSourceText([_$createComponent(py.ClassEnumDeclaration, {
|
|
40
40
|
name: "Color",
|
|
41
41
|
baseType: "IntEnum",
|
|
42
42
|
members: [{
|
|
@@ -64,7 +64,7 @@ describe("Python Enum", () => {
|
|
|
64
64
|
`;
|
|
65
65
|
expect(result).toRenderTo(expected);
|
|
66
66
|
});
|
|
67
|
-
it("
|
|
67
|
+
it("class enum with a refkey as jsValue", () => {
|
|
68
68
|
const result = toSourceText([_$createComponent(py.StatementList, {
|
|
69
69
|
get children() {
|
|
70
70
|
return [_$createComponent(py.ClassDeclaration, {
|
|
@@ -77,7 +77,7 @@ describe("Python Enum", () => {
|
|
|
77
77
|
get refkey() {
|
|
78
78
|
return refkey("Cat");
|
|
79
79
|
}
|
|
80
|
-
}), _$createComponent(py.
|
|
80
|
+
}), _$createComponent(py.ClassEnumDeclaration, {
|
|
81
81
|
name: "Animal",
|
|
82
82
|
baseType: "Enum",
|
|
83
83
|
get members() {
|
|
@@ -111,10 +111,10 @@ describe("Python Enum", () => {
|
|
|
111
111
|
`;
|
|
112
112
|
expect(result).toRenderTo(expected);
|
|
113
113
|
});
|
|
114
|
-
it("enum with auto() values", () => {
|
|
115
|
-
const result = toSourceText([_$createComponent(py.
|
|
114
|
+
it("class enum with auto() values", () => {
|
|
115
|
+
const result = toSourceText([_$createComponent(py.ClassEnumDeclaration, {
|
|
116
116
|
name: "Animal",
|
|
117
|
-
|
|
117
|
+
auto: true,
|
|
118
118
|
members: [{
|
|
119
119
|
name: "DOG"
|
|
120
120
|
}, {
|
|
@@ -138,11 +138,11 @@ describe("Python Enum", () => {
|
|
|
138
138
|
`;
|
|
139
139
|
expect(result).toRenderTo(expected);
|
|
140
140
|
});
|
|
141
|
-
it("enum with mixed manual and auto() values", () => {
|
|
142
|
-
const result = toSourceText([_$createComponent(py.
|
|
141
|
+
it("class enum with mixed manual and auto() values", () => {
|
|
142
|
+
const result = toSourceText([_$createComponent(py.ClassEnumDeclaration, {
|
|
143
143
|
name: "Permission",
|
|
144
144
|
baseType: "Flag",
|
|
145
|
-
|
|
145
|
+
auto: true,
|
|
146
146
|
members: [{
|
|
147
147
|
name: "READ",
|
|
148
148
|
value: 1
|
|
@@ -168,9 +168,8 @@ describe("Python Enum", () => {
|
|
|
168
168
|
expect(result).toRenderTo(expected);
|
|
169
169
|
});
|
|
170
170
|
it("functional enum with list", () => {
|
|
171
|
-
const result = toSourceText([_$createComponent(py.
|
|
171
|
+
const result = toSourceText([_$createComponent(py.FunctionalEnumDeclaration, {
|
|
172
172
|
name: "Direction",
|
|
173
|
-
style: "functional",
|
|
174
173
|
members: [{
|
|
175
174
|
name: "NORTH"
|
|
176
175
|
}, {
|
|
@@ -191,9 +190,8 @@ describe("Python Enum", () => {
|
|
|
191
190
|
expect(result).toRenderTo(expected);
|
|
192
191
|
});
|
|
193
192
|
it("functional enum with mapping", () => {
|
|
194
|
-
const result = toSourceText([_$createComponent(py.
|
|
193
|
+
const result = toSourceText([_$createComponent(py.FunctionalEnumDeclaration, {
|
|
195
194
|
name: "Priority",
|
|
196
|
-
style: "functional",
|
|
197
195
|
members: [{
|
|
198
196
|
name: "HIGH",
|
|
199
197
|
value: 1
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["refkey","d","describe","expect","it","enumModule","py","toSourceText","result","_$createComponent","
|
|
1
|
+
{"version":3,"names":["refkey","d","describe","expect","it","enumModule","py","toSourceText","result","_$createComponent","ClassEnumDeclaration","name","baseType","members","value","externals","expected","toRenderTo","jsValue","StatementList","children","ClassDeclaration","auto","FunctionalEnumDeclaration"],"sources":["../../test/enums.test.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,MAAM,QAAQ,gBAAgB;AACvC,SAASC,CAAC,QAAQ,wBAAwB;AAC1C,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC,UAAU,QAAQ,2BAA2B;AACtD,OAAO,KAAKC,EAAE,MAAM,iBAAiB;AACrC,SAASC,YAAY;AAErBL,QAAQ,CAAC,aAAa,EAAE,MAAM;EAC5BE,EAAE,CAAC,iCAAiC,EAAE,MAAM;IAC1C,MAAMI,MAAM,GAAGD,YAAY,CACzB,CAAAE,iBAAA,CACGH,EAAE,CAACI,oBAAoB;MACtBC,IAAI;MACJC,QAAQ;MACRC,OAAO,EAAE,CACP;QAAEF,IAAI,EAAE,KAAK;QAAEG,KAAK,EAAE;MAAI,CAAC,EAC3B;QAAEH,IAAI,EAAE,OAAO;QAAEG,KAAK,EAAE;MAAI,CAAC,EAC7B;QAAEH,IAAI,EAAE,MAAM;QAAEG,KAAK,EAAE;MAAI,CAAC;IAC7B,GAEJ,EACD;MAAEC,SAAS,EAAE,CAACV,UAAU;IAAE,CAC5B,CAAC;IACD,MAAMW,QAAQ,GAAGf,CAAC;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;IACDE,MAAM,CAACK,MAAM,CAAC,CAACS,UAAU,CAACD,QAAQ,CAAC;EACrC,CAAC,CAAC;EAEFZ,EAAE,CAAC,0BAA0B,EAAE,MAAM;IACnC,MAAMI,MAAM,GAAGD,YAAY,CACzB,CAAAE,iBAAA,CACGH,EAAE,CAACI,oBAAoB;MACtBC,IAAI;MACJC,QAAQ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E,CAAC,2BAA2B,EAAE,MAAM;IACpC,MAAMI,MAAM,GAAGD,YAAY,CACzB,CAAAE,iBAAA,CACGH,EAAE,CAACiB,yBAAyB;MAC3BZ,IAAI;MACJE,OAAO,EAAE,CACP;QAAEF,IAAI,EAAE;MAAQ,CAAC,EACjB;QAAEA,IAAI,EAAE;MAAQ,CAAC,EACjB;QAAEA,IAAI,EAAE;MAAO,CAAC,EAChB;QAAEA,IAAI,EAAE;MAAO,CAAC;IACjB,GAEJ,EACD;MAAEI,SAAS,EAAE,CAACV,UAAU;IAAE,CAC5B,CAAC;IACD,MAAMW,QAAQ,GAAGf,CAAC;AACtB;AACA;AACA;AACA,KAAK;IACDE,MAAM,CAACK,MAAM,CAAC,CAACS,UAAU,CAACD,QAAQ,CAAC;EACrC,CAAC,CAAC;EAEFZ,EAAE,CAAC,8BAA8B,EAAE,MAAM;IACvC,MAAMI,MAAM,GAAGD,YAAY,CACzB,CAAAE,iBAAA,CACGH,EAAE,CAACiB,yBAAyB;MAC3BZ,IAAI;MACJE,OAAO,EAAE,CACP;QAAEF,IAAI,EAAE,MAAM;QAAEG,KAAK,EAAE;MAAE,CAAC,EAC1B;QAAEH,IAAI,EAAE,QAAQ;QAAEG,KAAK,EAAE;MAAE,CAAC,EAC5B;QAAEH,IAAI,EAAE,KAAK;QAAEG,KAAK,EAAE;MAAE,CAAC;IAC1B,GAEJ,EACD;MAAEC,SAAS,EAAE,CAACV,UAAU;IAAE,CAC5B,CAAC;IACD,MAAMW,QAAQ,GAAGf,CAAC;AACtB;AACA;AACA;AACA,KAAK;IACDE,MAAM,CAACK,MAAM,CAAC,CAACS,UAAU,CAACD,QAAQ,CAAC;EACrC,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -128,7 +128,7 @@ it("uses import from external library in multiple class methods", () => {
|
|
|
128
128
|
get refkey() {
|
|
129
129
|
return refkey("some_var");
|
|
130
130
|
}
|
|
131
|
-
}), _$createComponent(py.
|
|
131
|
+
}), _$createComponent(py.MethodDeclaration, {
|
|
132
132
|
name: "getUser",
|
|
133
133
|
parameters: [{
|
|
134
134
|
name: "userId",
|
|
@@ -137,7 +137,6 @@ it("uses import from external library in multiple class methods", () => {
|
|
|
137
137
|
get returnType() {
|
|
138
138
|
return py.requestsModule["models"]["Response"];
|
|
139
139
|
},
|
|
140
|
-
instanceFunction: true,
|
|
141
140
|
get children() {
|
|
142
141
|
return _$createComponent(py.StatementList, {
|
|
143
142
|
get children() {
|
|
@@ -159,7 +158,7 @@ it("uses import from external library in multiple class methods", () => {
|
|
|
159
158
|
}
|
|
160
159
|
});
|
|
161
160
|
}
|
|
162
|
-
}), _$createComponent(py.
|
|
161
|
+
}), _$createComponent(py.MethodDeclaration, {
|
|
163
162
|
name: "createUser",
|
|
164
163
|
parameters: [{
|
|
165
164
|
name: "userName",
|
|
@@ -168,7 +167,6 @@ it("uses import from external library in multiple class methods", () => {
|
|
|
168
167
|
get returnType() {
|
|
169
168
|
return py.requestsModule["models"]["Response"];
|
|
170
169
|
},
|
|
171
|
-
instanceFunction: true,
|
|
172
170
|
get children() {
|
|
173
171
|
return _$createComponent(py.StatementList, {
|
|
174
172
|
get children() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["code","refkey","d","expect","it","py","createModule","toSourceText","requestsLib","name","descriptor","models","result","_$createComponent","StatementList","children","_$memo","get","post","Request","Response","something","externals","expected","toRenderTo","functionDeclarations","FunctionDeclaration","parameters","type","returnType","requestsModule","VariableDeclaration","initializer","FunctionCallExpression","target","args","ClassDeclaration","instanceVariable","
|
|
1
|
+
{"version":3,"names":["code","refkey","d","expect","it","py","createModule","toSourceText","requestsLib","name","descriptor","models","result","_$createComponent","StatementList","children","_$memo","get","post","Request","Response","something","externals","expected","toRenderTo","functionDeclarations","FunctionDeclaration","parameters","type","returnType","requestsModule","VariableDeclaration","initializer","FunctionCallExpression","target","args","ClassDeclaration","instanceVariable","MethodDeclaration"],"sources":["../../test/externals.test.tsx"],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Y,MAAM,GAAGL,YAAY,CAACkB,oBAAoB,EAAE;IAChDH,SAAS,EAAE,CAACjB,EAAE,CAACyB,cAAc;EAC/B,CAAC,CAAC;EACF,MAAMP,QAAQ,GAAGrB,CAAC;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;EACDC,MAAM,CAACS,MAAM,CAAC,CAACY,UAAU,CAACD,QAAQ,CAAC;AACrC,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factories.test.d.ts","sourceRoot":"","sources":["../../test/factories.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import * as py from "../src/index.js";
|
|
4
|
+
import { toSourceText } from "./utils.js";
|
|
5
|
+
describe("Symbol factories", () => {
|
|
6
|
+
it("createMethodSymbol throws outside class", () => {
|
|
7
|
+
expect(() => {
|
|
8
|
+
toSourceText([_$createComponent(py.MethodDeclaration, {
|
|
9
|
+
name: "m"
|
|
10
|
+
})]);
|
|
11
|
+
}).toThrow('Method "m" must be declared inside a class (member scope)');
|
|
12
|
+
});
|
|
13
|
+
it("createMethodSymbol succeeds inside class", () => {
|
|
14
|
+
const result = toSourceText([_$createComponent(py.ClassDeclaration, {
|
|
15
|
+
name: "C",
|
|
16
|
+
get children() {
|
|
17
|
+
return _$createComponent(py.MethodDeclaration, {
|
|
18
|
+
name: "m"
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
})]);
|
|
22
|
+
expect(result).toContain("def m(self):");
|
|
23
|
+
});
|
|
24
|
+
it("createFunctionSymbol usable in member scope (top-level function component still works nested)", () => {
|
|
25
|
+
const result = toSourceText([_$createComponent(py.ClassDeclaration, {
|
|
26
|
+
name: "C",
|
|
27
|
+
get children() {
|
|
28
|
+
return _$createComponent(py.StatementList, {
|
|
29
|
+
get children() {
|
|
30
|
+
return _$createComponent(py.FunctionDeclaration, {
|
|
31
|
+
name: "f"
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
})]);
|
|
37
|
+
// Nested free functions render without self/cls
|
|
38
|
+
expect(result).toContain("def f():");
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
describe("Validation Errors", () => {
|
|
42
|
+
it("throws error when PropertyDeclaration is used outside of a class", () => {
|
|
43
|
+
expect(() => {
|
|
44
|
+
toSourceText([_$createComponent(py.PropertyDeclaration, {
|
|
45
|
+
name: "x"
|
|
46
|
+
})]);
|
|
47
|
+
}).toThrow('Method "x" must be declared inside a class (member scope)');
|
|
48
|
+
});
|
|
49
|
+
it("throws error when MethodDeclaration is used outside of a class", () => {
|
|
50
|
+
expect(() => {
|
|
51
|
+
toSourceText([_$createComponent(py.MethodDeclaration, {
|
|
52
|
+
name: "my_method"
|
|
53
|
+
})]);
|
|
54
|
+
}).toThrow('Method "my_method" must be declared inside a class (member scope)');
|
|
55
|
+
});
|
|
56
|
+
it("throws error when ClassMethodDeclaration is used outside of a class", () => {
|
|
57
|
+
expect(() => {
|
|
58
|
+
toSourceText([_$createComponent(py.ClassMethodDeclaration, {
|
|
59
|
+
name: "my_class_method"
|
|
60
|
+
})]);
|
|
61
|
+
}).toThrow('Method "my_class_method" must be declared inside a class (member scope)');
|
|
62
|
+
});
|
|
63
|
+
it("throws error when StaticMethodDeclaration is used outside of a class", () => {
|
|
64
|
+
expect(() => {
|
|
65
|
+
toSourceText([_$createComponent(py.StaticMethodDeclaration, {
|
|
66
|
+
name: "my_static_method"
|
|
67
|
+
})]);
|
|
68
|
+
}).toThrow('Method "my_static_method" must be declared inside a class (member scope)');
|
|
69
|
+
});
|
|
70
|
+
it("throws error when DunderMethodDeclaration is used outside of a class", () => {
|
|
71
|
+
expect(() => {
|
|
72
|
+
toSourceText([_$createComponent(py.DunderMethodDeclaration, {
|
|
73
|
+
name: "__init__"
|
|
74
|
+
})]);
|
|
75
|
+
}).toThrow('Method "__init__" must be declared inside a class (member scope)');
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
//# sourceMappingURL=factories.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["describe","expect","it","py","toSourceText","_$createComponent","MethodDeclaration","name","toThrow","result","ClassDeclaration","children","toContain","StatementList","FunctionDeclaration","PropertyDeclaration","ClassMethodDeclaration","StaticMethodDeclaration","DunderMethodDeclaration"],"sources":["../../test/factories.test.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,OAAO,KAAKC,EAAE,MAAM,iBAAiB;AACrC,SAASC,YAAY,QAAQ,YAAY;AAEzCJ,QAAQ,CAAC,kBAAkB,EAAE,MAAM;EACjCE,EAAE,CAAC,yCAAyC,EAAE,MAAM;IAClDD,MAAM,CAAC,MAAM;MACXG,YAAY,CAAC,CAAAC,iBAAA,CAAEF,EAAE,CAACG,iBAAiB;QAACC,IAAI;MAAA,GAAQ,CAAC;IACnD,CAAC,CAAC,CAACC,OAAO,CAAC,2DAA2D,CAAC;EACzE,CAAC,CAAC;EAEFN,EAAE,CAAC,0CAA0C,EAAE,MAAM;IACnD,MAAMO,MAAM,GAAGL,YAAY,CAAC,CAAAC,iBAAA,CACzBF,EAAE,CAACO,gBAAgB;MAACH,IAAI;MAAA,IAAAI,SAAA;QAAA,OAAAN,iBAAA,CACtBF,EAAE,CAACG,iBAAiB;UAACC,IAAI;QAAA;MAAA;IAAA,GAE7B,CAAC;IACFN,MAAM,CAACQ,MAAM,CAAC,CAACG,SAAS,CAAC,cAAc,CAAC;EAC1C,CAAC,CAAC;EAEFV,EAAE,CAAC,+FAA+F,EAAE,MAAM;IACxG,MAAMO,MAAM,GAAGL,YAAY,CAAC,CAAAC,iBAAA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