chaokunyang commented on code in PR #3394: URL: https://github.com/apache/fory/pull/3394#discussion_r2890589263
########## integration_tests/idl_tests/javascript/roundtrip.ts: ########## @@ -0,0 +1,450 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Cross-language roundtrip program for TypeScript IDL tests. + * + * This script is invoked by the Java IdlRoundTripTest as a peer process. + * It reads binary data files (written by Java), deserializes them, + * re-serializes the objects, and writes the bytes back to the same files. + * Java then reads the files back and verifies the roundtrip integrity. + * + * Environment variables: + * IDL_COMPATIBLE - "true" for compatible mode, "false" for schema_consistent + * DATA_FILE - AddressBook binary data file path + * DATA_FILE_AUTO_ID - Envelope (auto-id) binary data file path + * DATA_FILE_PRIMITIVES - PrimitiveTypes binary data file path + * DATA_FILE_COLLECTION - NumericCollections binary data file path + * DATA_FILE_COLLECTION_UNION - NumericCollectionUnion binary data file path + * DATA_FILE_COLLECTION_ARRAY - NumericCollectionsArray binary data file path + * DATA_FILE_COLLECTION_ARRAY_UNION - NumericCollectionArrayUnion binary data file path + * DATA_FILE_OPTIONAL_TYPES - OptionalHolder binary data file path + * DATA_FILE_TREE - TreeNode binary data file path (ref tracking) + * DATA_FILE_GRAPH - Graph binary data file path (ref tracking) + * DATA_FILE_FLATBUFFERS_MONSTER - Monster binary data file path + * DATA_FILE_FLATBUFFERS_TEST2 - Container binary data file path + */ + +import * as fs from "fs"; +import Fory, { Type } from "@fory/fory"; + +const compatible = process.env["IDL_COMPATIBLE"] === "true"; + +// The Fory JS runtime does not support compatible mode (class metadata / Review Comment: [P2] Skipping all compatible-mode roundtrips here means we are not actually validating JavaScript behavior in compatible mode for this peer path. If compatible mode is intentionally unsupported in JS runtime, could we gate this test via explicit capability checks and document the coverage gap in test output/README to avoid a false sense of support? ########## docs/compiler/compiler-guide.md: ########## @@ -231,15 +232,16 @@ Compiling src/main.fdl... ## Supported Languages -| Language | Flag | Output Extension | Description | -| -------- | -------- | ---------------- | ---------------------------- | -| Java | `java` | `.java` | POJOs with Fory annotations | -| Python | `python` | `.py` | Dataclasses with type hints | -| Go | `go` | `.go` | Structs with struct tags | -| Rust | `rust` | `.rs` | Structs with derive macros | -| C++ | `cpp` | `.h` | Structs with FORY macros | -| C# | `csharp` | `.cs` | Classes with Fory attributes | -| Swift | `swift` | `.swift` | `@ForyObject` Swift models | +| Language | Flag | Output Extension | Description | +| ---------- | ------------ | ---------------- | ------------------------------------- | +| Java | `java` | `.java` | POJOs with Fory annotations | +| Python | `python` | `.py` | Dataclasses with type hints | +| Go | `go` | `.go` | Structs with struct tags | +| Rust | `rust` | `.rs` | Structs with derive macros | +| C++ | `cpp` | `.h` | Structs with FORY macros | +| C# | `csharp` | `.cs` | Classes with Fory attributes | +| JavaScript | `javascript` | `.js` | Interfaces with registration function | Review Comment: [P3] Doc/implementation mismatch: this table says JavaScript output extension is `.js`, but the generator currently emits `.ts` (`file_extension = ".ts"`). Please align docs and generated behavior so users do not target the wrong artifact type. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
