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