@@ -8,28 +8,28 @@ import (
88 "testing"
99)
1010
11- // TestMiscEqualCoverTransform verifies type-directed structural comparison.
11+ // TestCompareEqualCoverTransform verifies type-directed structural comparison.
1212//
13- // Issue #1497 adds `typia.misc .equal` and `typia.misc .cover`:
13+ // Issue #1497 adds `typia.compare .equal` and `typia.compare .cover`:
1414//
1515// 1. Transform direct and factory calls for equal/cover.
1616// 2. Execute object, partial-object, array-length, native, dynamic-key,
1717// union, and recursive pair-tracking cases.
1818// 3. Reject unsupported any, function, Set, Map, WeakSet, and WeakMap types
1919// at transform time.
20- func TestMiscEqualCoverTransform (t * testing.T ) {
21- project := miscEqualCoverProject (t , "misc -equal-cover-" , miscEqualCoverSource )
22- js := miscEqualCoverTransform (t , project )
20+ func TestCompareEqualCoverTransform (t * testing.T ) {
21+ project := compareEqualCoverProject (t , "compare -equal-cover-" , compareEqualCoverSource )
22+ js := compareEqualCoverTransform (t , project )
2323 for _ , needle := range []string {"getTime" , "source" , "flags" , "Uint8Array" , "WeakMap" , "_vctx" } {
2424 if ! strings .Contains (js , needle ) {
25- t .Fatalf ("misc equal/cover output is missing %q:\n %s" , needle , js )
25+ t .Fatalf ("compare equal/cover output is missing %q:\n %s" , needle , js )
2626 }
2727 }
28- miscEqualCoverRunRuntimeCases (t , project , js )
29- miscEqualCoverRejectsUnsupported (t )
28+ compareEqualCoverRunRuntimeCases (t , project , js )
29+ compareEqualCoverRejectsUnsupported (t )
3030}
3131
32- func miscEqualCoverProject (t * testing.T , prefix string , source string ) string {
32+ func compareEqualCoverProject (t * testing.T , prefix string , source string ) string {
3333 t .Helper ()
3434 root := ttscTypiaTestRepoRoot (t )
3535 base := filepath .Join (root , "packages" , "typia" , "native" , ".tmp-ttsc-typia-tests" )
@@ -47,7 +47,7 @@ func miscEqualCoverProject(t *testing.T, prefix string, source string) string {
4747 if err := os .MkdirAll (src , 0o755 ); err != nil {
4848 t .Fatalf ("mkdir fixture src: %v" , err )
4949 }
50- if err := os .WriteFile (filepath .Join (dir , "tsconfig.json" ), []byte (miscEqualCoverTSConfig ), 0o644 ); err != nil {
50+ if err := os .WriteFile (filepath .Join (dir , "tsconfig.json" ), []byte (compareEqualCoverTSConfig ), 0o644 ); err != nil {
5151 t .Fatalf ("write tsconfig: %v" , err )
5252 }
5353 if err := os .WriteFile (filepath .Join (src , "main.ts" ), []byte (source ), 0o644 ); err != nil {
@@ -56,7 +56,7 @@ func miscEqualCoverProject(t *testing.T, prefix string, source string) string {
5656 return dir
5757}
5858
59- func miscEqualCoverTransform (t * testing.T , project string ) string {
59+ func compareEqualCoverTransform (t * testing.T , project string ) string {
6060 t .Helper ()
6161 out , errText , code := ttscTypiaTestCapture (func () int {
6262 return runTransform ([]string {
@@ -67,12 +67,12 @@ func miscEqualCoverTransform(t *testing.T, project string) string {
6767 })
6868 })
6969 if code != 0 {
70- t .Fatalf ("misc equal/cover transform failed: code=%d stderr=\n %s" , code , errText )
70+ t .Fatalf ("compare equal/cover transform failed: code=%d stderr=\n %s" , code , errText )
7171 }
7272 return out
7373}
7474
75- func miscEqualCoverRunRuntimeCases (t * testing.T , project string , js string ) {
75+ func compareEqualCoverRunRuntimeCases (t * testing.T , project string , js string ) {
7676 t .Helper ()
7777 node , err := exec .LookPath ("node" )
7878 if err != nil {
@@ -88,33 +88,33 @@ func miscEqualCoverRunRuntimeCases(t *testing.T, project string, js string) {
8888 t .Fatalf ("write runtime module: %v" , err )
8989 }
9090 runner := filepath .Join (runtimeDir , "run.cjs" )
91- if err := os .WriteFile (runner , []byte (miscEqualCoverRuntimeRunner ), 0o644 ); err != nil {
91+ if err := os .WriteFile (runner , []byte (compareEqualCoverRuntimeRunner ), 0o644 ); err != nil {
9292 t .Fatalf ("write runtime runner: %v" , err )
9393 }
9494 cmd := exec .Command (node , runner )
9595 cmd .Dir = runtimeDir
9696 output , err := cmd .CombinedOutput ()
9797 if err != nil {
98- t .Fatalf ("misc equal/cover runtime cases failed: %v\n %s" , err , output )
98+ t .Fatalf ("compare equal/cover runtime cases failed: %v\n %s" , err , output )
9999 }
100100}
101101
102- func miscEqualCoverRejectsUnsupported (t * testing.T ) {
102+ func compareEqualCoverRejectsUnsupported (t * testing.T ) {
103103 t .Helper ()
104104 cases := []struct {
105105 Name string
106106 Source string
107107 }{
108- {"any" , "export const bad = typia.misc .createEqual<any>();" },
109- {"function" , "export const bad = typia.misc .createEqual<() => void>();" },
110- {"set" , "export const bad = typia.misc .createCover<Set<string>>();" },
111- {"map" , "export const bad = typia.misc .createEqual<Map<string, number>>();" },
112- {"weak-set" , "export const bad = typia.misc .createCover<WeakSet<object>>();" },
113- {"weak-map" , "export const bad = typia.misc .createEqual<WeakMap<object, object>>();" },
108+ {"any" , "export const bad = typia.compare .createEqual<any>();" },
109+ {"function" , "export const bad = typia.compare .createEqual<() => void>();" },
110+ {"set" , "export const bad = typia.compare .createCover<Set<string>>();" },
111+ {"map" , "export const bad = typia.compare .createEqual<Map<string, number>>();" },
112+ {"weak-set" , "export const bad = typia.compare .createCover<WeakSet<object>>();" },
113+ {"weak-map" , "export const bad = typia.compare .createEqual<WeakMap<object, object>>();" },
114114 }
115115 for _ , tc := range cases {
116116 t .Run (tc .Name , func (t * testing.T ) {
117- project := miscEqualCoverProject (t , "misc -equal-cover-reject-" , `import typia from "typia";
117+ project := compareEqualCoverProject (t , "compare -equal-cover-reject-" , `import typia from "typia";
118118` + tc .Source + `
119119` )
120120 out , errText , code := ttscTypiaTestCapture (func () int {
@@ -133,7 +133,7 @@ func miscEqualCoverRejectsUnsupported(t *testing.T) {
133133 }
134134}
135135
136- const miscEqualCoverTSConfig = `{
136+ const compareEqualCoverTSConfig = `{
137137 "compilerOptions": {
138138 "target": "ES2022",
139139 "module": "commonjs",
@@ -148,7 +148,7 @@ const miscEqualCoverTSConfig = `{
148148}
149149`
150150
151- const miscEqualCoverSource = `import typia, { misc } from "typia";
151+ const compareEqualCoverSource = `import typia, { compare } from "typia";
152152
153153interface IUser {
154154 name: string;
@@ -164,34 +164,34 @@ interface IUser {
164164 bytes: Uint8Array;
165165}
166166
167- export const equalUser = typia.misc .createEqual<IUser>();
168- export const coverUser = typia.misc .createCover<IUser>();
169- export const equalUserDirect = (x: IUser, y: IUser) => typia.misc .equal<IUser>(x, y);
170- export const coverUserDirect = (x: IUser, y: misc .Cover<IUser>) => typia.misc .cover<IUser>(x, y);
167+ export const equalUser = typia.compare .createEqual<IUser>();
168+ export const coverUser = typia.compare .createCover<IUser>();
169+ export const equalUserDirect = (x: IUser, y: IUser) => typia.compare .equal<IUser>(x, y);
170+ export const coverUserDirect = (x: IUser, y: compare .Cover<IUser>) => typia.compare .cover<IUser>(x, y);
171171
172172interface IDictionary {
173173 fixed: string;
174174 [key: string]: string;
175175}
176- export const equalDictionary = typia.misc .createEqual<IDictionary>();
177- export const coverDictionary = typia.misc .createCover<IDictionary>();
176+ export const equalDictionary = typia.compare .createEqual<IDictionary>();
177+ export const coverDictionary = typia.compare .createCover<IDictionary>();
178178
179179type Shape =
180180 | { kind: "circle"; radius: number; nested: { label: string } }
181181 | { kind: "square"; size: number; nested: { label: string } };
182- export const equalShape = typia.misc .createEqual<Shape>();
183- export const coverShape = typia.misc .createCover<Shape>();
182+ export const equalShape = typia.compare .createEqual<Shape>();
183+ export const coverShape = typia.compare .createCover<Shape>();
184184
185185interface INode {
186186 id: number;
187187 next: INode | null;
188188 children: INode[];
189189}
190- export const equalNode = typia.misc .createEqual<INode>();
191- export const coverNode = typia.misc .createCover<INode>();
190+ export const equalNode = typia.compare .createEqual<INode>();
191+ export const coverNode = typia.compare .createCover<INode>();
192192`
193193
194- const miscEqualCoverRuntimeRunner = `const mod = require("./main.cjs");
194+ const compareEqualCoverRuntimeRunner = `const mod = require("./main.cjs");
195195
196196const expect = (label, actual, expected) => {
197197 if (actual !== expected) {
0 commit comments