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