@alloy-js/python 0.5.0-dev.0 → 0.5.0-dev.2
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 +46 -0
- package/dist/dev/src/builtins/python.js.map +1 -1
- package/dist/dev/src/components/ClassDeclaration.js +19 -10
- package/dist/dev/src/components/ClassDeclaration.js.map +1 -1
- package/dist/dev/src/components/ClassMethodDeclaration.js +20 -5
- package/dist/dev/src/components/ClassMethodDeclaration.js.map +1 -1
- package/dist/dev/src/components/DataclassDeclaration.js +14 -12
- package/dist/dev/src/components/DataclassDeclaration.js.map +1 -1
- package/dist/dev/src/components/DecoratorList.js +55 -0
- package/dist/dev/src/components/DecoratorList.js.map +1 -0
- package/dist/dev/src/components/EnumDeclaration.js +21 -12
- package/dist/dev/src/components/EnumDeclaration.js.map +1 -1
- package/dist/dev/src/components/FunctionBase.js +21 -10
- package/dist/dev/src/components/FunctionBase.js.map +1 -1
- package/dist/dev/src/components/FutureStatement.js +1 -1
- package/dist/dev/src/components/MethodBase.js +16 -4
- package/dist/dev/src/components/MethodBase.js.map +1 -1
- package/dist/dev/src/components/PropertyDeclaration.js +68 -17
- package/dist/dev/src/components/PropertyDeclaration.js.map +1 -1
- package/dist/dev/src/components/PydanticClassDeclaration.js +136 -0
- package/dist/dev/src/components/PydanticClassDeclaration.js.map +1 -0
- package/dist/dev/src/components/SourceFile.js +44 -32
- package/dist/dev/src/components/SourceFile.js.map +1 -1
- package/dist/dev/src/components/StaticMethodDeclaration.js +19 -5
- package/dist/dev/src/components/StaticMethodDeclaration.js.map +1 -1
- package/dist/dev/src/components/index.js +1 -0
- package/dist/dev/src/components/index.js.map +1 -1
- package/dist/dev/test/callsignatures.test.js +471 -297
- package/dist/dev/test/callsignatures.test.js.map +1 -1
- package/dist/dev/test/class-method-declaration.test.js +21 -10
- package/dist/dev/test/class-method-declaration.test.js.map +1 -1
- package/dist/dev/test/classdeclarations.test.js +480 -381
- package/dist/dev/test/classdeclarations.test.js.map +1 -1
- package/dist/dev/test/classinstantiations.test.js +201 -168
- package/dist/dev/test/classinstantiations.test.js.map +1 -1
- package/dist/dev/test/constructordeclaration.test.js +22 -11
- package/dist/dev/test/constructordeclaration.test.js.map +1 -1
- package/dist/dev/test/dataclassdeclarations.test.js +345 -358
- package/dist/dev/test/dataclassdeclarations.test.js.map +1 -1
- package/dist/dev/test/decoratorlist.test.js +131 -0
- package/dist/dev/test/decoratorlist.test.js.map +1 -0
- package/dist/dev/test/dundermethoddeclaration.test.js +22 -11
- package/dist/dev/test/dundermethoddeclaration.test.js.map +1 -1
- package/dist/dev/test/enums.test.js +231 -166
- package/dist/dev/test/enums.test.js.map +1 -1
- package/dist/dev/test/externals.test.js +57 -45
- package/dist/dev/test/externals.test.js.map +1 -1
- package/dist/dev/test/factories.test.js +124 -50
- package/dist/dev/test/factories.test.js.map +1 -1
- package/dist/dev/test/functioncallexpressions.test.js +199 -164
- package/dist/dev/test/functioncallexpressions.test.js.map +1 -1
- package/dist/dev/test/functiondeclaration.test.js +452 -265
- package/dist/dev/test/functiondeclaration.test.js.map +1 -1
- package/dist/dev/test/imports.test.js +273 -221
- package/dist/dev/test/imports.test.js.map +1 -1
- package/dist/dev/test/memberexpressions.test.js +1237 -972
- package/dist/dev/test/memberexpressions.test.js.map +1 -1
- package/dist/dev/test/methoddeclaration.test.js +200 -45
- package/dist/dev/test/methoddeclaration.test.js.map +1 -1
- package/dist/dev/test/namepolicies.test.js +130 -94
- package/dist/dev/test/namepolicies.test.js.map +1 -1
- package/dist/dev/test/propertydeclaration.test.js +177 -46
- package/dist/dev/test/propertydeclaration.test.js.map +1 -1
- package/dist/dev/test/pydanticclassdeclarations.test.js +1089 -0
- package/dist/dev/test/pydanticclassdeclarations.test.js.map +1 -0
- package/dist/dev/test/pydocs.test.js +888 -715
- package/dist/dev/test/pydocs.test.js.map +1 -1
- package/dist/dev/test/references.test.js +42 -35
- package/dist/dev/test/references.test.js.map +1 -1
- package/dist/dev/test/sourcefiles.test.js +1109 -841
- package/dist/dev/test/sourcefiles.test.js.map +1 -1
- package/dist/dev/test/staticmethoddeclaration.test.js +21 -10
- package/dist/dev/test/staticmethoddeclaration.test.js.map +1 -1
- package/dist/dev/test/type-checking-imports.test.js +408 -359
- package/dist/dev/test/type-checking-imports.test.js.map +1 -1
- package/dist/dev/test/typereference.test.js +55 -40
- package/dist/dev/test/typereference.test.js.map +1 -1
- package/dist/dev/test/uniontypeexpression.test.js +222 -146
- package/dist/dev/test/uniontypeexpression.test.js.map +1 -1
- package/dist/dev/test/utils.js +39 -77
- package/dist/dev/test/utils.js.map +1 -1
- package/dist/dev/test/values.test.js +237 -101
- package/dist/dev/test/values.test.js.map +1 -1
- package/dist/dev/test/variables.test.js +321 -203
- package/dist/dev/test/variables.test.js.map +1 -1
- package/dist/dev/test/vitest.setup.js +2 -0
- package/dist/dev/test/vitest.setup.js.map +1 -0
- package/dist/src/builtins/python.d.ts +30 -0
- package/dist/src/builtins/python.d.ts.map +1 -1
- package/dist/src/builtins/python.js +46 -0
- package/dist/src/builtins/python.js.map +1 -1
- package/dist/src/components/ClassDeclaration.d.ts +21 -0
- package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
- package/dist/src/components/ClassDeclaration.js +6 -1
- package/dist/src/components/ClassDeclaration.js.map +1 -1
- package/dist/src/components/ClassMethodDeclaration.d.ts +5 -1
- package/dist/src/components/ClassMethodDeclaration.d.ts.map +1 -1
- package/dist/src/components/ClassMethodDeclaration.js +14 -3
- package/dist/src/components/ClassMethodDeclaration.js.map +1 -1
- package/dist/src/components/DataclassDeclaration.d.ts.map +1 -1
- package/dist/src/components/DataclassDeclaration.js +10 -4
- package/dist/src/components/DataclassDeclaration.js.map +1 -1
- package/dist/src/components/DecoratorList.d.ts +43 -0
- package/dist/src/components/DecoratorList.d.ts.map +1 -0
- package/dist/src/components/DecoratorList.js +47 -0
- package/dist/src/components/DecoratorList.js.map +1 -0
- package/dist/src/components/EnumDeclaration.d.ts +9 -0
- package/dist/src/components/EnumDeclaration.d.ts.map +1 -1
- package/dist/src/components/EnumDeclaration.js +6 -1
- package/dist/src/components/EnumDeclaration.js.map +1 -1
- package/dist/src/components/FunctionBase.d.ts +31 -1
- package/dist/src/components/FunctionBase.d.ts.map +1 -1
- package/dist/src/components/FunctionBase.js +9 -2
- package/dist/src/components/FunctionBase.js.map +1 -1
- package/dist/src/components/FutureStatement.d.ts +1 -1
- package/dist/src/components/FutureStatement.js +1 -1
- package/dist/src/components/MethodBase.d.ts.map +1 -1
- package/dist/src/components/MethodBase.js +10 -2
- package/dist/src/components/MethodBase.js.map +1 -1
- package/dist/src/components/PropertyDeclaration.d.ts +29 -0
- package/dist/src/components/PropertyDeclaration.d.ts.map +1 -1
- package/dist/src/components/PropertyDeclaration.js +48 -1
- package/dist/src/components/PropertyDeclaration.js.map +1 -1
- package/dist/src/components/PydanticClassDeclaration.d.ts +120 -0
- package/dist/src/components/PydanticClassDeclaration.d.ts.map +1 -0
- package/dist/src/components/PydanticClassDeclaration.js +116 -0
- package/dist/src/components/PydanticClassDeclaration.js.map +1 -0
- package/dist/src/components/SourceFile.d.ts +2 -2
- package/dist/src/components/SourceFile.d.ts.map +1 -1
- package/dist/src/components/SourceFile.js +12 -0
- package/dist/src/components/SourceFile.js.map +1 -1
- package/dist/src/components/StaticMethodDeclaration.d.ts +3 -0
- package/dist/src/components/StaticMethodDeclaration.d.ts.map +1 -1
- package/dist/src/components/StaticMethodDeclaration.js +13 -3
- package/dist/src/components/StaticMethodDeclaration.js.map +1 -1
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +1 -0
- package/dist/src/components/index.js.map +1 -1
- package/dist/test/callsignatures.test.js +346 -272
- package/dist/test/callsignatures.test.js.map +1 -1
- package/dist/test/class-method-declaration.test.js +7 -4
- package/dist/test/class-method-declaration.test.js.map +1 -1
- package/dist/test/classdeclarations.test.js +316 -277
- package/dist/test/classdeclarations.test.js.map +1 -1
- package/dist/test/classinstantiations.test.js +112 -103
- package/dist/test/classinstantiations.test.js.map +1 -1
- package/dist/test/constructordeclaration.test.js +7 -4
- package/dist/test/constructordeclaration.test.js.map +1 -1
- package/dist/test/dataclassdeclarations.test.js +153 -178
- package/dist/test/dataclassdeclarations.test.js.map +1 -1
- package/dist/test/decoratorlist.test.d.ts +2 -0
- package/dist/test/decoratorlist.test.d.ts.map +1 -0
- package/dist/test/decoratorlist.test.js +83 -0
- package/dist/test/decoratorlist.test.js.map +1 -0
- package/dist/test/dundermethoddeclaration.test.js +7 -4
- package/dist/test/dundermethoddeclaration.test.js.map +1 -1
- package/dist/test/enums.test.js +172 -143
- package/dist/test/enums.test.js.map +1 -1
- package/dist/test/externals.test.js +24 -24
- package/dist/test/externals.test.js.map +1 -1
- package/dist/test/factories.test.js +75 -33
- package/dist/test/factories.test.js.map +1 -1
- package/dist/test/functioncallexpressions.test.js +117 -106
- package/dist/test/functioncallexpressions.test.js.map +1 -1
- package/dist/test/functiondeclaration.test.js +256 -173
- package/dist/test/functiondeclaration.test.js.map +1 -1
- package/dist/test/imports.test.js +171 -143
- package/dist/test/imports.test.js.map +1 -1
- package/dist/test/memberexpressions.test.js +582 -453
- package/dist/test/memberexpressions.test.js.map +1 -1
- package/dist/test/methoddeclaration.test.js +106 -19
- package/dist/test/methoddeclaration.test.js.map +1 -1
- package/dist/test/namepolicies.test.js +90 -78
- package/dist/test/namepolicies.test.js.map +1 -1
- package/dist/test/propertydeclaration.test.js +90 -15
- package/dist/test/propertydeclaration.test.js.map +1 -1
- package/dist/test/pydanticclassdeclarations.test.d.ts +2 -0
- package/dist/test/pydanticclassdeclarations.test.d.ts.map +1 -0
- package/dist/test/pydanticclassdeclarations.test.js +773 -0
- package/dist/test/pydanticclassdeclarations.test.js.map +1 -0
- package/dist/test/pydocs.test.js +573 -532
- package/dist/test/pydocs.test.js.map +1 -1
- package/dist/test/references.test.js +31 -28
- package/dist/test/references.test.js.map +1 -1
- package/dist/test/sourcefiles.test.js +700 -580
- package/dist/test/sourcefiles.test.js.map +1 -1
- package/dist/test/staticmethoddeclaration.test.js +7 -4
- package/dist/test/staticmethoddeclaration.test.js.map +1 -1
- package/dist/test/type-checking-imports.test.js +297 -284
- package/dist/test/type-checking-imports.test.js.map +1 -1
- package/dist/test/typereference.test.js +29 -22
- package/dist/test/typereference.test.js.map +1 -1
- package/dist/test/uniontypeexpression.test.js +124 -88
- package/dist/test/uniontypeexpression.test.js.map +1 -1
- package/dist/test/utils.d.ts +10 -17
- package/dist/test/utils.d.ts.map +1 -1
- package/dist/test/utils.js +32 -74
- package/dist/test/utils.js.map +1 -1
- package/dist/test/values.test.js +135 -67
- package/dist/test/values.test.js.map +1 -1
- package/dist/test/variables.test.js +201 -151
- package/dist/test/variables.test.js.map +1 -1
- package/dist/test/vitest.setup.d.ts +2 -0
- package/dist/test/vitest.setup.d.ts.map +1 -0
- package/dist/test/vitest.setup.js +2 -0
- package/dist/test/vitest.setup.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/docs/api/components/ClassDeclaration.md +10 -7
- package/docs/api/components/ClassEnumDeclaration.md +9 -6
- package/docs/api/components/ClassMethodDeclaration.md +7 -5
- package/docs/api/components/DataclassDeclaration.md +9 -5
- package/docs/api/components/DunderMethodDeclaration.md +7 -5
- package/docs/api/components/FunctionDeclaration.md +9 -5
- package/docs/api/components/FutureStatement.md +1 -1
- package/docs/api/components/MethodDeclaration.md +11 -6
- package/docs/api/components/PropertyDeclaration.md +11 -8
- package/docs/api/components/PydanticClassDeclaration.md +146 -0
- package/docs/api/components/SourceFile.md +20 -8
- package/docs/api/components/StaticMethodDeclaration.md +7 -5
- package/docs/api/components/index.md +1 -0
- package/docs/api/index.md +3 -3
- package/docs/api/types/CommonFunctionProps.md +4 -3
- package/docs/api/types/PydanticModelConfigDictProps.md +32 -0
- package/docs/api/types/index.md +1 -0
- package/docs/api/variables/index.md +3 -0
- package/docs/api/variables/pydanticModule.md +27 -0
- package/docs/api/variables/pydanticSettingsModule.md +7 -0
- package/docs/api/variables/typingModule.md +9 -0
- package/package.json +4 -4
- package/src/builtins/python.ts +539 -1
- package/src/components/ClassDeclaration.tsx +23 -0
- package/src/components/ClassMethodDeclaration.tsx +9 -1
- package/src/components/DataclassDeclaration.tsx +18 -11
- package/src/components/DecoratorList.tsx +50 -0
- package/src/components/EnumDeclaration.tsx +11 -0
- package/src/components/FunctionBase.tsx +34 -3
- package/src/components/FutureStatement.tsx +1 -1
- package/src/components/MethodBase.tsx +6 -2
- package/src/components/PropertyDeclaration.tsx +48 -1
- package/src/components/PydanticClassDeclaration.tsx +222 -0
- package/src/components/SourceFile.tsx +6 -1
- package/src/components/StaticMethodDeclaration.tsx +7 -1
- package/src/components/index.ts +1 -0
- package/temp/api.json +1158 -86
- package/test/callsignatures.test.tsx +309 -283
- package/test/class-method-declaration.test.tsx +3 -4
- package/test/classdeclarations.test.tsx +277 -235
- package/test/classinstantiations.test.tsx +115 -109
- package/test/constructordeclaration.test.tsx +9 -6
- package/test/dataclassdeclarations.test.tsx +256 -349
- package/test/decoratorlist.test.tsx +114 -0
- package/test/dundermethoddeclaration.test.tsx +3 -4
- package/test/enums.test.tsx +84 -71
- package/test/externals.test.tsx +25 -25
- package/test/factories.test.tsx +64 -22
- package/test/functioncallexpressions.test.tsx +123 -109
- package/test/functiondeclaration.test.tsx +218 -140
- package/test/imports.test.tsx +119 -91
- package/test/memberexpressions.test.tsx +265 -207
- package/test/methoddeclaration.test.tsx +115 -24
- package/test/namepolicies.test.tsx +69 -69
- package/test/propertydeclaration.test.tsx +71 -7
- package/test/pydanticclassdeclarations.test.tsx +704 -0
- package/test/pydocs.test.tsx +531 -579
- package/test/references.test.tsx +24 -23
- package/test/sourcefiles.test.tsx +527 -492
- package/test/staticmethoddeclaration.test.tsx +3 -4
- package/test/type-checking-imports.test.tsx +206 -218
- package/test/typereference.test.tsx +15 -12
- package/test/uniontypeexpression.test.tsx +74 -61
- package/test/utils.tsx +26 -110
- package/test/values.test.tsx +82 -32
- package/test/variables.test.tsx +162 -142
- package/test/vitest.setup.ts +1 -0
- package/vitest.config.ts +3 -0
package/dist/test/utils.js
CHANGED
|
@@ -1,86 +1,44 @@
|
|
|
1
|
-
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { Output
|
|
3
|
-
import { dedent } from "@alloy-js/core/testing";
|
|
4
|
-
import { expect } from "vitest";
|
|
1
|
+
import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { Output } from "@alloy-js/core";
|
|
5
3
|
import * as py from "../src/components/index.js";
|
|
6
4
|
import { pythonNameConflictResolver } from "../src/name-conflict-resolver.js";
|
|
7
5
|
import { createPythonNamePolicy } from "../src/name-policy.js";
|
|
8
6
|
import { PythonModuleScope } from "../src/symbols/index.js";
|
|
9
|
-
export function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return
|
|
7
|
+
export function TestOutput(props) {
|
|
8
|
+
return _$createComponent(Output, {
|
|
9
|
+
get externals() {
|
|
10
|
+
return props.externals;
|
|
11
|
+
},
|
|
12
|
+
get namePolicy() {
|
|
13
|
+
return props.namePolicy ?? createPythonNamePolicy();
|
|
14
|
+
},
|
|
15
|
+
nameConflictResolver: pythonNameConflictResolver,
|
|
16
|
+
get children() {
|
|
17
|
+
return _$createComponent(py.SourceFile, {
|
|
18
|
+
get path() {
|
|
19
|
+
return props.path ?? "test.py";
|
|
20
|
+
},
|
|
21
|
+
printWidth: 80,
|
|
22
|
+
get children() {
|
|
23
|
+
return props.children;
|
|
26
24
|
}
|
|
27
|
-
}
|
|
25
|
+
});
|
|
28
26
|
}
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
export function assertFileContents(res, expectedFiles) {
|
|
33
|
-
for (const [path, contents] of Object.entries(expectedFiles)) {
|
|
34
|
-
const file = findFile(res, path);
|
|
35
|
-
expect(file.contents).toBe(dedent(contents));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
export function toSourceTextMultiple(sourceFiles, {
|
|
39
|
-
policy,
|
|
40
|
-
externals,
|
|
41
|
-
options,
|
|
42
|
-
printOptions
|
|
43
|
-
} = {}) {
|
|
44
|
-
if (!policy) {
|
|
45
|
-
policy = createPythonNamePolicy();
|
|
46
|
-
}
|
|
47
|
-
const mergedExternals = options?.externals ?? externals;
|
|
48
|
-
if (printOptions === undefined) {
|
|
49
|
-
printOptions = {
|
|
50
|
-
printWidth: 80,
|
|
51
|
-
tabWidth: 4,
|
|
52
|
-
insertFinalNewLine: false
|
|
53
|
-
};
|
|
54
|
-
} else {
|
|
55
|
-
printOptions.insertFinalNewLine = false;
|
|
56
|
-
printOptions.tabWidth = 4;
|
|
57
|
-
}
|
|
58
|
-
const content = _$createComponent(Output, {
|
|
59
|
-
externals: mergedExternals,
|
|
60
|
-
namePolicy: policy,
|
|
61
|
-
nameConflictResolver: pythonNameConflictResolver,
|
|
62
|
-
children: sourceFiles
|
|
63
27
|
});
|
|
64
|
-
return render(content, printOptions);
|
|
65
28
|
}
|
|
66
|
-
export function
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
children
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
policy,
|
|
79
|
-
externals,
|
|
80
|
-
options,
|
|
81
|
-
printOptions
|
|
29
|
+
export function TestOutputDirectory(props) {
|
|
30
|
+
return _$createComponent(Output, {
|
|
31
|
+
get externals() {
|
|
32
|
+
return props.externals;
|
|
33
|
+
},
|
|
34
|
+
get namePolicy() {
|
|
35
|
+
return props.namePolicy ?? createPythonNamePolicy();
|
|
36
|
+
},
|
|
37
|
+
nameConflictResolver: pythonNameConflictResolver,
|
|
38
|
+
get children() {
|
|
39
|
+
return props.children;
|
|
40
|
+
}
|
|
82
41
|
});
|
|
83
|
-
return findFile(res, path).contents;
|
|
84
42
|
}
|
|
85
43
|
|
|
86
44
|
// Helper function to create a PythonModuleScope to be used in tests
|
package/dist/test/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Output","
|
|
1
|
+
{"version":3,"names":["Output","py","pythonNameConflictResolver","createPythonNamePolicy","PythonModuleScope","TestOutput","props","_$createComponent","externals","namePolicy","nameConflictResolver","children","SourceFile","path","printWidth","TestOutputDirectory","createPythonModuleScope","name","parent","binder","undefined"],"sources":["../../test/utils.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAIEA,MAAM,QAGD,gBAAgB;AACvB,OAAO,KAAKC,EAAE,MAAM,4BAA4B;AAChD,SAASC,0BAA0B,QAAQ,kCAAkC;AAC7E,SAASC,sBAAsB,QAAQ,uBAAuB;AAC9D,SAASC,iBAAiB,QAAQ,yBAAyB;AAE3D,OAAO,SAASC,UAAUA,CAACC,KAK1B,EAAE;EACD,OAAAC,iBAAA,CACGP,MAAM;IAAA,IACLQ,SAASA,CAAA;MAAA,OAAEF,KAAK,CAACE,SAAS;IAAA;IAAA,IAC1BC,UAAUA,CAAA;MAAA,OAAEH,KAAK,CAACG,UAAU,IAAIN,sBAAsB,CAAC,CAAC;IAAA;IACxDO,oBAAoB,EAAER,0BAA0B;IAAA,IAAAS,SAAA;MAAA,OAAAJ,iBAAA,CAE/CN,EAAE,CAACW,UAAU;QAAA,IAACC,IAAIA,CAAA;UAAA,OAAEP,KAAK,CAACO,IAAI,IAAI,SAAS;QAAA;QAAEC,UAAU,EAAE,EAAE;QAAA,IAAAH,SAAA;UAAA,OACzDL,KAAK,CAACK,QAAQ;QAAA;MAAA;IAAA;EAAA;AAIvB;AAEA,OAAO,SAASI,mBAAmBA,CAACT,KAInC,EAAE;EACD,OAAAC,iBAAA,CACGP,MAAM;IAAA,IACLQ,SAASA,CAAA;MAAA,OAAEF,KAAK,CAACE,SAAS;IAAA;IAAA,IAC1BC,UAAUA,CAAA;MAAA,OAAEH,KAAK,CAACG,UAAU,IAAIN,sBAAsB,CAAC,CAAC;IAAA;IACxDO,oBAAoB,EAAER,0BAA0B;IAAA,IAAAS,SAAA;MAAA,OAE/CL,KAAK,CAACK,QAAQ;IAAA;EAAA;AAGrB;;AAEA;AACA,OAAO,SAASK,uBAAuBA,CACrCC,IAAY,EACZC,MAA+B,EAC/BC,MAA0B,GAAGC,SAAS,EACnB;EACnB,OAAO,IAAIhB,iBAAiB,CAACa,IAAI,EAAEC,MAAM,EAAE;IACzCC,MAAM,EAAEA;EACV,CAAC,CAAC;AACJ","ignoreList":[]}
|
package/dist/test/values.test.js
CHANGED
|
@@ -1,114 +1,182 @@
|
|
|
1
1
|
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import { describe, expect, it } from "vitest";
|
|
3
3
|
import * as py from "../src/index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { TestOutput } from "./utils.js";
|
|
5
5
|
describe("Atom", () => {
|
|
6
6
|
it("renders string value", () => {
|
|
7
|
-
expect(
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
expect(_$createComponent(TestOutput, {
|
|
8
|
+
get children() {
|
|
9
|
+
return _$createComponent(py.Atom, {
|
|
10
|
+
jsValue: "Test"
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
})).toRenderTo('"Test"');
|
|
10
14
|
});
|
|
11
15
|
it("renders null/undefined object", () => {
|
|
12
|
-
expect(
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
expect(_$createComponent(TestOutput, {
|
|
17
|
+
get children() {
|
|
18
|
+
return _$createComponent(py.Atom, {
|
|
19
|
+
jsValue: undefined
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
})).toRenderTo("None");
|
|
15
23
|
});
|
|
16
24
|
it("renders number", () => {
|
|
17
|
-
expect(
|
|
18
|
-
|
|
19
|
-
|
|
25
|
+
expect(_$createComponent(TestOutput, {
|
|
26
|
+
get children() {
|
|
27
|
+
return _$createComponent(py.Atom, {
|
|
28
|
+
jsValue: 123
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
})).toRenderTo("123");
|
|
20
32
|
});
|
|
21
33
|
it("renders floating point number", () => {
|
|
22
|
-
expect(
|
|
23
|
-
|
|
24
|
-
|
|
34
|
+
expect(_$createComponent(TestOutput, {
|
|
35
|
+
get children() {
|
|
36
|
+
return _$createComponent(py.Atom, {
|
|
37
|
+
jsValue: 123.456
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
})).toRenderTo("123.456");
|
|
25
41
|
});
|
|
26
42
|
it("renders floating point number when hinted", () => {
|
|
27
|
-
expect(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
43
|
+
expect(_$createComponent(TestOutput, {
|
|
44
|
+
get children() {
|
|
45
|
+
return _$createComponent(py.Atom, {
|
|
46
|
+
jsValue: 123.456,
|
|
47
|
+
asFloat: true
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
})).toRenderTo("123.456");
|
|
31
51
|
});
|
|
32
52
|
it("renders floating point number with decimal point zero when hinted", () => {
|
|
33
|
-
expect(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
53
|
+
expect(_$createComponent(TestOutput, {
|
|
54
|
+
get children() {
|
|
55
|
+
return _$createComponent(py.Atom, {
|
|
56
|
+
jsValue: 123.0,
|
|
57
|
+
asFloat: true
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
})).toRenderTo("123.0");
|
|
37
61
|
});
|
|
38
62
|
it("renders integer as float when hinted", () => {
|
|
39
|
-
expect(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
63
|
+
expect(_$createComponent(TestOutput, {
|
|
64
|
+
get children() {
|
|
65
|
+
return _$createComponent(py.Atom, {
|
|
66
|
+
jsValue: 123,
|
|
67
|
+
asFloat: true
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
})).toRenderTo("123.0");
|
|
43
71
|
});
|
|
44
72
|
it("renders small positive float when hinted", () => {
|
|
45
|
-
expect(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
73
|
+
expect(_$createComponent(TestOutput, {
|
|
74
|
+
get children() {
|
|
75
|
+
return _$createComponent(py.Atom, {
|
|
76
|
+
jsValue: 0.07,
|
|
77
|
+
asFloat: true
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
})).toRenderTo("0.07");
|
|
49
81
|
});
|
|
50
82
|
it("renders large positive numbers as float when hinted", () => {
|
|
51
|
-
expect(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
83
|
+
expect(_$createComponent(TestOutput, {
|
|
84
|
+
get children() {
|
|
85
|
+
return _$createComponent(py.Atom, {
|
|
86
|
+
jsValue: 2 ** 64,
|
|
87
|
+
asFloat: true
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
})).toRenderTo("18446744073709551616.0");
|
|
55
91
|
});
|
|
56
92
|
it("renders boolean - True", () => {
|
|
57
|
-
expect(
|
|
58
|
-
|
|
59
|
-
|
|
93
|
+
expect(_$createComponent(TestOutput, {
|
|
94
|
+
get children() {
|
|
95
|
+
return _$createComponent(py.Atom, {
|
|
96
|
+
jsValue: true
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
})).toRenderTo("True");
|
|
60
100
|
});
|
|
61
101
|
it("renders boolean - False", () => {
|
|
62
|
-
expect(
|
|
63
|
-
|
|
64
|
-
|
|
102
|
+
expect(_$createComponent(TestOutput, {
|
|
103
|
+
get children() {
|
|
104
|
+
return _$createComponent(py.Atom, {
|
|
105
|
+
jsValue: false
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
})).toRenderTo("False");
|
|
65
109
|
});
|
|
66
110
|
it("renders array", () => {
|
|
67
|
-
expect(
|
|
68
|
-
|
|
69
|
-
|
|
111
|
+
expect(_$createComponent(TestOutput, {
|
|
112
|
+
get children() {
|
|
113
|
+
return _$createComponent(py.Atom, {
|
|
114
|
+
jsValue: [1, 2, 3]
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
})).toRenderTo("[1, 2, 3]");
|
|
70
118
|
});
|
|
71
119
|
it("renders object", () => {
|
|
72
|
-
expect(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
120
|
+
expect(_$createComponent(TestOutput, {
|
|
121
|
+
get children() {
|
|
122
|
+
return _$createComponent(py.Atom, {
|
|
123
|
+
jsValue: {
|
|
124
|
+
a: 1,
|
|
125
|
+
b: 2
|
|
126
|
+
}
|
|
127
|
+
});
|
|
76
128
|
}
|
|
77
|
-
})
|
|
129
|
+
})).toRenderTo('{"a": 1, "b": 2}');
|
|
78
130
|
});
|
|
79
131
|
it("renders more complex object", () => {
|
|
80
|
-
expect(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
132
|
+
expect(_$createComponent(TestOutput, {
|
|
133
|
+
get children() {
|
|
134
|
+
return _$createComponent(py.Atom, {
|
|
135
|
+
jsValue: {
|
|
136
|
+
a: "1",
|
|
137
|
+
b: 2,
|
|
138
|
+
c: true
|
|
139
|
+
}
|
|
140
|
+
});
|
|
85
141
|
}
|
|
86
|
-
})
|
|
142
|
+
})).toRenderTo('{"a": "1", "b": 2, "c": True}');
|
|
87
143
|
});
|
|
88
144
|
it("renders empty object", () => {
|
|
89
|
-
expect(
|
|
90
|
-
|
|
91
|
-
|
|
145
|
+
expect(_$createComponent(TestOutput, {
|
|
146
|
+
get children() {
|
|
147
|
+
return _$createComponent(py.Atom, {
|
|
148
|
+
jsValue: {}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
})).toRenderTo("{}");
|
|
92
152
|
});
|
|
93
153
|
it("renders function", () => {
|
|
94
154
|
function Test() {
|
|
95
155
|
return ["Test"];
|
|
96
156
|
}
|
|
97
|
-
expect(
|
|
98
|
-
|
|
99
|
-
|
|
157
|
+
expect(_$createComponent(TestOutput, {
|
|
158
|
+
get children() {
|
|
159
|
+
return _$createComponent(py.Atom, {
|
|
160
|
+
jsValue: Test
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
})).toRenderTo("Test");
|
|
100
164
|
});
|
|
101
165
|
it("renders nested object", () => {
|
|
102
|
-
expect(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
166
|
+
expect(_$createComponent(TestOutput, {
|
|
167
|
+
get children() {
|
|
168
|
+
return _$createComponent(py.Atom, {
|
|
169
|
+
jsValue: {
|
|
170
|
+
a: {
|
|
171
|
+
b: {
|
|
172
|
+
c: 1
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
d: 2
|
|
107
176
|
}
|
|
108
|
-
}
|
|
109
|
-
d: 2
|
|
177
|
+
});
|
|
110
178
|
}
|
|
111
|
-
})
|
|
179
|
+
})).toRenderTo('{"a": {"b": {"c": 1}}, "d": 2}');
|
|
112
180
|
});
|
|
113
181
|
});
|
|
114
182
|
//# sourceMappingURL=values.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["describe","expect","it","py","
|
|
1
|
+
{"version":3,"names":["describe","expect","it","py","TestOutput","_$createComponent","children","Atom","jsValue","toRenderTo","undefined","asFloat","a","b","c","Test","d"],"sources":["../../test/values.test.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,OAAO,KAAKC,EAAE,MAAM,iBAAiB;AACrC,SAASC,UAAU,QAAQ,YAAY;AAEvCJ,QAAQ,CAAC,MAAM,EAAE,MAAM;EACrBE,EAAE,CAAC,sBAAsB,EAAE,MAAM;IAC/BD,MAAM,CAAAI,iBAAA,CACHD,UAAU;MAAA,IAAAE,SAAA;QAAA,OAAAD,i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