blob: c836550bd324abe57ba03efacfe7682e7321536c [file] [log] [blame]
Cameron Martincaef0ed2025-01-15 11:58:39 +01001"use strict";
wilfrem2c69b5a2015-04-20 19:24:50 +09002
Cameron Martincaef0ed2025-01-15 11:58:39 +01003import ttypes = require("./gen-nodejs/ThriftTest_types");
4import Int64 = require("node-int64");
CJCombrinkdfeab8d2026-03-06 07:03:56 +01005import { v4 as uuidv4, v7 as uuidv7 } from 'uuid';
wilfrem2c69b5a2015-04-20 19:24:50 +09006
7//all Languages in UTF-8
8/*jshint -W100 */
Cameron Martincaef0ed2025-01-15 11:58:39 +01009export var stringTest =
10 "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, " +
11 "Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, " +
12 "Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, " +
13 "বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, " +
14 "Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, " +
15 "Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, " +
16 "Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, " +
17 "Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, " +
18 "Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, " +
19 "Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, " +
20 "Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, " +
21 "ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, " +
22 "Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, " +
23 "Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa " +
24 "Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, مازِرونی, Bahasa " +
25 "Melayu, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, ‪" +
26 "Norsk (nynorsk)‬, ‪Norsk (bokmål)‬, Nouormand, Diné bizaad, " +
27 "Occitan, Иронау, Papiamentu, Deitsch, Polski, پنجابی, پښتو, " +
28 "Norfuk / Pitkern, Português, Runa Simi, Rumantsch, Romani, Română, " +
29 "Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple " +
30 "English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, " +
31 "Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, " +
32 "Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, " +
33 "Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, " +
34 "Bân-lâm-gú, 粵語";
wilfrem2c69b5a2015-04-20 19:24:50 +090035/*jshint +W100 */
36
Cameron Martincaef0ed2025-01-15 11:58:39 +010037export var specialCharacters =
38 'quote: \" backslash:' +
39 " forwardslash-escaped: \/ " +
40 " backspace: \b formfeed: \f newline: \n return: \r tab: " +
41 ' now-all-of-them-together: "\\\/\b\n\r\t' +
42 " now-a-bunch-of-junk: !@#$%&()(&%$#{}{}<><><" +
43 ' char-to-test-json-parsing: ]] \"]] \\" }}}{ [[[ ';
wilfrem2c69b5a2015-04-20 19:24:50 +090044
45export var mapTestInput = {
Cameron Martincaef0ed2025-01-15 11:58:39 +010046 a: "123",
47 "a b": "with spaces ",
48 same: "same",
49 "0": "numeric key",
50 longValue: stringTest,
51 stringTest: "long key",
wilfrem2c69b5a2015-04-20 19:24:50 +090052};
53
54export var simple = [
Cameron Martincaef0ed2025-01-15 11:58:39 +010055 ["testVoid", undefined],
56 ["testString", "Test"],
57 ["testString", ""],
58 ["testString", stringTest],
59 ["testString", specialCharacters],
60 ["testByte", 1],
61 ["testByte", 0],
62 ["testByte", -1],
63 ["testByte", -127],
64 ["testI32", -1],
65 ["testDouble", -5.2098523],
66 ["testDouble", 7.012052175215044],
67 ["testEnum", ttypes.Numberz.ONE],
CJCombrinkdfeab8d2026-03-06 07:03:56 +010068 ["testUuid", "00112233-4455-6677-8899-aabbccddeeff"],
69 ["testUuid", uuidv4()],
70 ["testUuid", uuidv7()],
wilfrem2c69b5a2015-04-20 19:24:50 +090071];
72
73export var simpleLoose = [
Cameron Martincaef0ed2025-01-15 11:58:39 +010074 ["testI64", 5],
75 ["testI64", -5],
76 ["testI64", 734359738368],
77 ["testI64", -34359738368],
78 ["testI64", -734359738368],
79 ["testTypedef", 69],
80];
wilfrem2c69b5a2015-04-20 19:24:50 +090081
Cameron Martincaef0ed2025-01-15 11:58:39 +010082var mapout: { [key: number]: number } = {};
wilfrem2c69b5a2015-04-20 19:24:50 +090083for (var i = 0; i < 5; ++i) {
Cameron Martincaef0ed2025-01-15 11:58:39 +010084 mapout[i] = i - 10;
wilfrem2c69b5a2015-04-20 19:24:50 +090085}
86
87export var deep = [
Cameron Martincaef0ed2025-01-15 11:58:39 +010088 ["testMap", mapout],
89 ["testSet", [1, 2, 3]],
90 [
91 "testList",
92 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],
93 ],
94 ["testStringMap", mapTestInput],
wilfrem2c69b5a2015-04-20 19:24:50 +090095];
96
97export var out = new ttypes.Xtruct({
Cameron Martincaef0ed2025-01-15 11:58:39 +010098 string_thing: "Zero",
wilfrem2c69b5a2015-04-20 19:24:50 +090099 byte_thing: 1,
100 i32_thing: -3,
Cameron Martincaef0ed2025-01-15 11:58:39 +0100101 i64_thing: new Int64(1000000),
wilfrem2c69b5a2015-04-20 19:24:50 +0900102});
103
104export var out2 = new ttypes.Xtruct2();
105out2.byte_thing = 1;
106out2.struct_thing = out;
107out2.i32_thing = 5;
108
109export var crazy = new ttypes.Insanity({
Cameron Martincaef0ed2025-01-15 11:58:39 +0100110 userMap: { "5": new Int64(5), "8": new Int64(8) },
111 xtructs: [
112 new ttypes.Xtruct({
113 string_thing: "Goodbye4",
114 byte_thing: 4,
115 i32_thing: 4,
116 i64_thing: new Int64(4),
117 }),
118 new ttypes.Xtruct({
119 string_thing: "Hello2",
120 byte_thing: 2,
121 i32_thing: 2,
122 i64_thing: new Int64(2),
123 }),
124 ],
wilfrem2c69b5a2015-04-20 19:24:50 +0900125});
126
127export var insanity: any = {
Cameron Martincaef0ed2025-01-15 11:58:39 +0100128 "1": { "2": crazy, "3": crazy },
129 "2": { "6": { userMap: {}, xtructs: [] } },
wilfrem2c69b5a2015-04-20 19:24:50 +0900130};