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'); |
Nobuaki Sukegawa | f56b907 | 2015-11-23 19:38:18 +0900 | [diff] [blame] | 4 | var Int64 = require('node-int64'); |
Randy Abernethy | 3b9ff4d | 2015-02-16 00:51:24 -0800 | [diff] [blame] | 5 | |
| 6 | //all Languages in UTF-8 |
| 7 | /*jshint -W100 */ |
| 8 | var stringTest = module.exports.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 | var specialCharacters = module.exports.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 | var mapTestInput = module.exports.mapTestInput = { |
| 43 | "a":"123", "a b":"with spaces ", "same":"same", "0":"numeric key", |
| 44 | "longValue":stringTest, stringTest:"long key" |
| 45 | }; |
| 46 | |
| 47 | var simple = [ |
| 48 | ['testVoid', undefined], |
| 49 | ['testString', 'Test'], |
| 50 | ['testString', ''], |
| 51 | ['testString', stringTest], |
| 52 | ['testString', specialCharacters], |
Nobuaki Sukegawa | a649e74 | 2015-09-21 13:53:25 +0900 | [diff] [blame] | 53 | ['testBool', true], |
| 54 | ['testBool', false], |
Randy Abernethy | 3b9ff4d | 2015-02-16 00:51:24 -0800 | [diff] [blame] | 55 | ['testByte', 1], |
| 56 | ['testByte', 0], |
| 57 | ['testByte', -1], |
| 58 | ['testByte', -127], |
| 59 | ['testI32', -1], |
Randy Abernethy | d8187c5 | 2015-02-16 01:25:53 -0800 | [diff] [blame] | 60 | ['testDouble', -5.2098523], |
| 61 | ['testDouble', 7.012052175215044], |
Nobuaki Sukegawa | f56b907 | 2015-11-23 19:38:18 +0900 | [diff] [blame] | 62 | ['testEnum', ttypes.Numberz.ONE], |
Randy Abernethy | 3b9ff4d | 2015-02-16 00:51:24 -0800 | [diff] [blame] | 63 | ['testI64', 5], |
| 64 | ['testI64', -5], |
| 65 | ['testI64', 734359738368], |
Randy Abernethy | 3b9ff4d | 2015-02-16 00:51:24 -0800 | [diff] [blame] | 66 | ['testI64', -734359738368], |
Nobuaki Sukegawa | f56b907 | 2015-11-23 19:38:18 +0900 | [diff] [blame] | 67 | ['testI64', new Int64(new Buffer([0, 0x20, 0, 0, 0, 0, 0, 1]))], // 2^53+1 |
| 68 | ['testI64', new Int64( |
| 69 | new Buffer([0xff, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]))], // -2^53-1 |
Randy Abernethy | 3b9ff4d | 2015-02-16 00:51:24 -0800 | [diff] [blame] | 70 | ['testTypedef', 69] |
Randy Abernethy | d8187c5 | 2015-02-16 01:25:53 -0800 | [diff] [blame] | 71 | ] |
Randy Abernethy | 3b9ff4d | 2015-02-16 00:51:24 -0800 | [diff] [blame] | 72 | |
| 73 | var mapout = {}; |
| 74 | for (var i = 0; i < 5; ++i) { |
| 75 | mapout[i] = i-10; |
| 76 | } |
| 77 | |
Randy Abernethy | 3b9ff4d | 2015-02-16 00:51:24 -0800 | [diff] [blame] | 78 | var deep = [ |
Randy Abernethy | 983bf7d | 2015-10-09 12:28:57 -0700 | [diff] [blame] | 79 | ['testList', [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]], |
| 80 | ]; |
| 81 | |
| 82 | var deepUnordered = [ |
Randy Abernethy | 3b9ff4d | 2015-02-16 00:51:24 -0800 | [diff] [blame] | 83 | ['testMap', mapout], |
| 84 | ['testSet', [1,2,3]], |
Randy Abernethy | 3b9ff4d | 2015-02-16 00:51:24 -0800 | [diff] [blame] | 85 | ['testStringMap', mapTestInput] |
| 86 | ]; |
| 87 | |
| 88 | var out = new ttypes.Xtruct({ |
| 89 | string_thing: 'Zero', |
| 90 | byte_thing: 1, |
| 91 | i32_thing: -3, |
| 92 | i64_thing: 1000000 |
| 93 | }); |
| 94 | |
| 95 | var out2 = new ttypes.Xtruct2(); |
| 96 | out2.byte_thing = 1; |
| 97 | out2.struct_thing = out; |
| 98 | out2.i32_thing = 5; |
| 99 | |
| 100 | var crazy = new ttypes.Insanity({ |
| 101 | "userMap":{ "5":5, "8":8 }, |
| 102 | "xtructs":[new ttypes.Xtruct({ |
| 103 | "string_thing":"Goodbye4", |
| 104 | "byte_thing":4, |
| 105 | "i32_thing":4, |
| 106 | "i64_thing":4 |
| 107 | }), new ttypes.Xtruct({ |
| 108 | "string_thing":"Hello2", |
| 109 | "byte_thing":2, |
| 110 | "i32_thing":2, |
| 111 | "i64_thing":2 |
| 112 | })] |
| 113 | }); |
| 114 | |
Henrique Mendonça | 15d9042 | 2015-06-25 22:31:41 +1000 | [diff] [blame] | 115 | var crazy2 = new ttypes.Insanity({ |
| 116 | "userMap":{ "5":5, "8":8 }, |
| 117 | "xtructs":[{ |
| 118 | "string_thing":"Goodbye4", |
| 119 | "byte_thing":4, |
| 120 | "i32_thing":4, |
| 121 | "i64_thing":4 |
| 122 | }, { |
| 123 | "string_thing":"Hello2", |
| 124 | "byte_thing":2, |
| 125 | "i32_thing":2, |
| 126 | "i64_thing":2 |
| 127 | }] |
| 128 | }); |
| 129 | |
| 130 | |
Randy Abernethy | 3b9ff4d | 2015-02-16 00:51:24 -0800 | [diff] [blame] | 131 | var insanity = { |
| 132 | "1":{ "2": crazy, "3": crazy }, |
| 133 | "2":{ "6":{ "userMap":{}, "xtructs":[] } } |
| 134 | }; |
| 135 | |
| 136 | module.exports.simple = simple; |
Randy Abernethy | 3b9ff4d | 2015-02-16 00:51:24 -0800 | [diff] [blame] | 137 | module.exports.deep = deep; |
Randy Abernethy | 983bf7d | 2015-10-09 12:28:57 -0700 | [diff] [blame] | 138 | module.exports.deepUnordered = deepUnordered; |
Randy Abernethy | 3b9ff4d | 2015-02-16 00:51:24 -0800 | [diff] [blame] | 139 | |
| 140 | module.exports.out = out; |
| 141 | module.exports.out2 = out2; |
| 142 | module.exports.crazy = crazy; |
Henrique Mendonça | 15d9042 | 2015-06-25 22:31:41 +1000 | [diff] [blame] | 143 | module.exports.crazy2 = crazy2; |
Randy Abernethy | 3b9ff4d | 2015-02-16 00:51:24 -0800 | [diff] [blame] | 144 | module.exports.insanity = insanity; |