How to use convert method in storybook-root

Best JavaScript code snippet using storybook-root

index.test.ts

Source:index.test.ts Github

copy

Full Screen

2import { convert as bahtLatest } from 'baht';3const { ThaiBaht: thaiBahtText } = require('thai-baht-text-ts');4describe('convert', () => {5 it('works', () => {6 expect(convert(0)).toBe('ศูนย์บาทถ้วน');7 expect(convert(1)).toBe('หนึ่งบาทถ้วน');8 expect(convert(2)).toBe('สองบาทถ้วน');9 expect(convert(5)).toBe('ห้าบาทถ้วน');10 expect(convert(9)).toBe('เก้าบาทถ้วน');11 expect(convert(10)).toBe('สิบบาทถ้วน');12 expect(convert(20)).toBe('ยี่สิบบาทถ้วน');13 expect(convert(30)).toBe('สามสิบบาทถ้วน');14 expect(convert(45)).toBe('สี่สิบห้าบาทถ้วน');15 expect(convert(100)).toBe('หนึ่งร้อยบาทถ้วน');16 expect(convert(122)).toBe('หนึ่งร้อยยี่สิบสองบาทถ้วน');17 expect(convert(190)).toBe('หนึ่งร้อยเก้าสิบบาทถ้วน');18 expect(convert(290)).toBe('สองร้อยเก้าสิบบาทถ้วน');19 expect(convert(1000)).toBe('หนึ่งพันบาทถ้วน');20 expect(convert(10000)).toBe('หนึ่งหมื่นบาทถ้วน');21 expect(convert(100000)).toBe('หนึ่งแสนบาทถ้วน');22 expect(convert(100001)).toBe('หนึ่งแสนเอ็ดบาทถ้วน');23 expect(convert(100005)).toBe('หนึ่งแสนห้าบาทถ้วน');24 expect(convert(100021)).toBe('หนึ่งแสนยี่สิบเอ็ดบาทถ้วน');25 expect(convert(1000000)).toBe('หนึ่งล้านบาทถ้วน');26 expect(convert(1002000)).toBe('หนึ่งล้านสองพันบาทถ้วน');27 expect(convert(10000000)).toBe('สิบล้านบาทถ้วน');28 expect(convert(10002000)).toBe('สิบล้านสองพันบาทถ้วน');29 });30 it('returns false for bad inputs', () => {31 expect(convert('hello')).toBe(false);32 expect(convert((false as unknown) as number)).toBe(false);33 expect(convert((true as unknown) as number)).toBe(false);34 expect(convert(({} as unknown) as number)).toBe(false);35 expect(convert(([] as unknown) as number)).toBe(false);36 expect(convert(('155233.4b6' as unknown) as number)).toBe(false);37 expect(convert(('155233.476a85' as unknown) as number)).toBe(false);38 });39 it('should be a function', () => {40 expect(convert).toEqual(expect.any(Function));41 });42 it('convert to 0', () => {43 expect(convert(0)).toEqual('ศูนย์บาทถ้วน');44 expect(convert(0.0)).toEqual('ศูนย์บาทถ้วน');45 expect(convert(0.0001)).toEqual('ศูนย์บาทถ้วน');46 expect(convert(0.001)).toEqual('ศูนย์บาทถ้วน');47 expect(convert(0.009)).toEqual('ศูนย์บาทถ้วน');48 });49 it('should convert to Satang', () => {50 expect(convert(0.01)).toEqual('หนึ่งสตางค์');51 expect(convert(0.1)).toEqual('สิบสตางค์');52 expect(convert(0.1)).toEqual('สิบสตางค์');53 expect(convert(0.11)).toEqual('สิบเอ็ดสตางค์');54 expect(convert(0.12)).toEqual('สิบสองสตางค์');55 expect(convert(0.123)).toEqual('สิบสองสตางค์');56 expect(convert(0.2)).toEqual('ยี่สิบสตางค์');57 expect(convert(0.2)).toEqual('ยี่สิบสตางค์');58 expect(convert(0.21)).toEqual('ยี่สิบเอ็ดสตางค์');59 expect(convert(0.25)).toEqual('ยี่สิบห้าสตางค์');60 expect(convert(0.255)).toEqual('ยี่สิบห้าสตางค์');61 expect(convert(0.5)).toEqual('ห้าสิบสตางค์');62 expect(convert(0.75)).toEqual('เจ็ดสิบห้าสตางค์');63 expect(convert(0.99)).toEqual('เก้าสิบเก้าสตางค์');64 expect(convert(0.999)).toEqual('เก้าสิบเก้าสตางค์');65 });66 it('should convert to Baht', () => {67 expect(convert(1)).toEqual('หนึ่งบาทถ้วน');68 expect(convert(10)).toEqual('สิบบาทถ้วน');69 expect(convert(11)).toEqual('สิบเอ็ดบาทถ้วน');70 expect(convert(12)).toEqual('สิบสองบาทถ้วน');71 expect(convert(20)).toEqual('ยี่สิบบาทถ้วน');72 expect(convert(21)).toEqual('ยี่สิบเอ็ดบาทถ้วน');73 expect(convert(22)).toEqual('ยี่สิบสองบาทถ้วน');74 expect(convert(100)).toEqual('หนึ่งร้อยบาทถ้วน');75 expect(convert(101)).toEqual('หนึ่งร้อยเอ็ดบาทถ้วน');76 expect(convert(111)).toEqual('หนึ่งร้อยสิบเอ็ดบาทถ้วน');77 expect(convert(121)).toEqual('หนึ่งร้อยยี่สิบเอ็ดบาทถ้วน');78 });79 it('should convert to negative baht', () => {80 expect(convert(-1)).toEqual('ลบหนึ่งบาทถ้วน');81 expect(convert(-10)).toEqual('ลบสิบบาทถ้วน');82 expect(convert(-11)).toEqual('ลบสิบเอ็ดบาทถ้วน');83 expect(convert(-12)).toEqual('ลบสิบสองบาทถ้วน');84 expect(convert(-20)).toEqual('ลบยี่สิบบาทถ้วน');85 expect(convert(-21)).toEqual('ลบยี่สิบเอ็ดบาทถ้วน');86 expect(convert(-22)).toEqual('ลบยี่สิบสองบาทถ้วน');87 expect(convert(-100)).toEqual('ลบหนึ่งร้อยบาทถ้วน');88 expect(convert(-101)).toEqual('ลบหนึ่งร้อยเอ็ดบาทถ้วน');89 expect(convert(-111)).toEqual('ลบหนึ่งร้อยสิบเอ็ดบาทถ้วน');90 expect(convert(-121)).toEqual('ลบหนึ่งร้อยยี่สิบเอ็ดบาทถ้วน');91 });92 it('should convert 1-99 satangs correctly compared to baht', () => {93 const bahtArray = [];94 const satangArray = [];95 for (let i = 1; i < 100; i++) {96 bahtArray.push((convert(i) as string).replace('บาทถ้วน', ''));97 satangArray.push(98 (convert(+`0.${i.toString().padStart(2, '0')}`) as string).replace(99 'สตางค์',100 ''101 )102 );103 }104 expect(bahtArray).toEqual(satangArray);105 });106 it('should convert big number to Baht', () => {107 expect(convert(1000000)).toEqual('หนึ่งล้านบาทถ้วน');108 expect(convert(1000001)).toEqual('หนึ่งล้านเอ็ดบาทถ้วน');109 expect(convert(11000001)).toEqual('สิบเอ็ดล้านเอ็ดบาทถ้วน');110 expect(convert(11000000)).toEqual('สิบเอ็ดล้านบาทถ้วน');111 expect(convert(21000000)).toEqual('ยี่สิบเอ็ดล้านบาทถ้วน');112 expect(convert(21000010)).toEqual('ยี่สิบเอ็ดล้านสิบบาทถ้วน');113 expect(convert(21000011)).toEqual('ยี่สิบเอ็ดล้านสิบเอ็ดบาทถ้วน');114 expect(convert(121000011)).toEqual('หนึ่งร้อยยี่สิบเอ็ดล้านสิบเอ็ดบาทถ้วน');115 });116 it('should convert multiple million round to Baht', () => {117 expect(convert(1000000000000000000)).toEqual('หนึ่งล้านล้านล้านบาทถ้วน');118 expect(convert(1000000000001)).toEqual('หนึ่งล้านล้านเอ็ดบาทถ้วน');119 expect(convert(1000000000000)).toEqual('หนึ่งล้านล้านบาทถ้วน');120 expect(convert(1001000000001)).toEqual('หนึ่งล้านหนึ่งพันล้านเอ็ดบาทถ้วน');121 expect(convert(1001000001001)).toEqual(122 'หนึ่งล้านหนึ่งพันล้านหนึ่งพันเอ็ดบาทถ้วน'123 );124 expect(convert(1001000000000)).toEqual('หนึ่งล้านหนึ่งพันล้านบาทถ้วน');125 expect(convert(1000000000)).toEqual('หนึ่งพันล้านบาทถ้วน');126 expect(convert(10000000)).toEqual('สิบล้านบาทถ้วน');127 expect(convert(100000000)).toEqual('หนึ่งร้อยล้านบาทถ้วน');128 // Safe integer129 expect(convert(9007199254740991)).toEqual(130 'เก้าพันเจ็ดล้านหนึ่งแสนเก้าหมื่นเก้าพันสองร้อยห้าสิบสี่ล้านเจ็ดแสนสี่หมื่นเก้าร้อยเก้าสิบเอ็ดบาทถ้วน'131 );132 });133 it('should convert complex number to Baht', () => {134 expect(convert(6321298)).toEqual(135 'หกล้านสามแสนสองหมื่นหนึ่งพันสองร้อยเก้าสิบแปดบาทถ้วน'136 );137 expect(convert(10034567)).toEqual(138 'สิบล้านสามหมื่นสี่พันห้าร้อยหกสิบเจ็ดบาทถ้วน'139 );140 expect(convert(20034567)).toEqual(141 'ยี่สิบล้านสามหมื่นสี่พันห้าร้อยหกสิบเจ็ดบาทถ้วน'142 );143 expect(convert(30034567.0)).toEqual(144 'สามสิบล้านสามหมื่นสี่พันห้าร้อยหกสิบเจ็ดบาทถ้วน'145 );146 expect(convert(1534325986.4336942)).toEqual(147 'หนึ่งพันห้าร้อยสามสิบสี่ล้านสามแสนสองหมื่นห้าพันเก้าร้อยแปดสิบหกบาทสี่สิบสามสตางค์'148 );149 });150 it('should convert number to Baht with Satang', () => {151 expect(convert(11.25)).toEqual('สิบเอ็ดบาทยี่สิบห้าสตางค์');152 expect(convert(100.5)).toEqual('หนึ่งร้อยบาทห้าสิบสตางค์');153 expect(convert(567.01)).toEqual('ห้าร้อยหกสิบเจ็ดบาทหนึ่งสตางค์');154 expect(convert(123456789.999)).toEqual(155 'หนึ่งร้อยยี่สิบสามล้านสี่แสนห้าหมื่นหกพันเจ็ดร้อยแปดสิบเก้าบาทเก้าสิบเก้าสตางค์'156 );157 });158 it('should convert number in string format', () => {159 expect(convert(('1234' as unknown) as number)).toBe(160 'หนึ่งพันสองร้อยสามสิบสี่บาทถ้วน'161 );162 expect(convert(('-1' as unknown) as number)).toBe('ลบหนึ่งบาทถ้วน');163 expect(convert(('-30' as unknown) as number)).toBe('ลบสามสิบบาทถ้วน');164 expect(convert(('123456789.999' as unknown) as number)).toEqual(165 'หนึ่งร้อยยี่สิบสามล้านสี่แสนห้าหมื่นหกพันเจ็ดร้อยแปดสิบเก้าบาทเก้าสิบเก้าสตางค์'166 );167 expect(convert(('4123001998830750501' as unknown) as number)).toBe(168 'สี่ล้านหนึ่งแสนสองหมื่นสามพันเอ็ดล้านเก้าแสนเก้าหมื่นแปดพันแปดร้อยสามสิบล้านเจ็ดแสนห้าหมื่นห้าร้อยเอ็ดบาทถ้วน'169 );170 expect(convert(('-4123001998830750501' as unknown) as number)).toBe(171 'ลบสี่ล้านหนึ่งแสนสองหมื่นสามพันเอ็ดล้านเก้าแสนเก้าหมื่นแปดพันแปดร้อยสามสิบล้านเจ็ดแสนห้าหมื่นห้าร้อยเอ็ดบาทถ้วน'172 );173 expect(convert(('-4123001998830750501.21' as unknown) as number)).toBe(174 'ลบสี่ล้านหนึ่งแสนสองหมื่นสามพันเอ็ดล้านเก้าแสนเก้าหมื่นแปดพันแปดร้อยสามสิบล้านเจ็ดแสนห้าหมื่นห้าร้อยเอ็ดบาทยี่สิบเอ็ดสตางค์'175 );176 expect(convert(('-1654321.21' as unknown) as number)).toBe(177 'ลบหนึ่งล้านหกแสนห้าหมื่นสี่พันสามร้อยยี่สิบเอ็ดบาทยี่สิบเอ็ดสตางค์'178 );179 expect(convert(('152555.4' as unknown) as number)).toBe(180 'หนึ่งแสนห้าหมื่นสองพันห้าร้อยห้าสิบห้าบาทสี่สิบสตางค์'181 );182 expect((convert('535.') as unknown) as number).toBe(183 'ห้าร้อยสามสิบห้าบาทถ้วน'184 );185 });186 it('should convert with leading zero before the decimal point in string format.', () => {187 expect(convert(('0' as unknown) as number)).toBe('ศูนย์บาทถ้วน');188 expect(convert(('-0' as unknown) as number)).toBe('ศูนย์บาทถ้วน');189 expect(convert(('09.05' as unknown) as number)).toBe('เก้าบาทห้าสตางค์');190 expect(convert(('11' as unknown) as number)).toBe('สิบเอ็ดบาทถ้วน');191 expect(convert(('01234' as unknown) as number)).toBe(192 'หนึ่งพันสองร้อยสามสิบสี่บาทถ้วน'193 );194 expect(convert(('-01' as unknown) as number)).toBe('ลบหนึ่งบาทถ้วน');195 expect(convert(('-011' as unknown) as number)).toBe('ลบสิบเอ็ดบาทถ้วน');196 expect(convert(('-021' as unknown) as number)).toBe('ลบยี่สิบเอ็ดบาทถ้วน');197 expect(convert(('-030' as unknown) as number)).toBe('ลบสามสิบบาทถ้วน');198 expect(convert(('0123456789.999' as unknown) as number)).toEqual(199 'หนึ่งร้อยยี่สิบสามล้านสี่แสนห้าหมื่นหกพันเจ็ดร้อยแปดสิบเก้าบาทเก้าสิบเก้าสตางค์'200 );201 expect(convert(('04123001998830750501' as unknown) as number)).toBe(202 'สี่ล้านหนึ่งแสนสองหมื่นสามพันเอ็ดล้านเก้าแสนเก้าหมื่นแปดพันแปดร้อยสามสิบล้านเจ็ดแสนห้าหมื่นห้าร้อยเอ็ดบาทถ้วน'203 );204 expect(convert(('-04123001998830750501' as unknown) as number)).toBe(205 'ลบสี่ล้านหนึ่งแสนสองหมื่นสามพันเอ็ดล้านเก้าแสนเก้าหมื่นแปดพันแปดร้อยสามสิบล้านเจ็ดแสนห้าหมื่นห้าร้อยเอ็ดบาทถ้วน'206 );207 expect(convert(('-04123001998830750501.21' as unknown) as number)).toBe(208 'ลบสี่ล้านหนึ่งแสนสองหมื่นสามพันเอ็ดล้านเก้าแสนเก้าหมื่นแปดพันแปดร้อยสามสิบล้านเจ็ดแสนห้าหมื่นห้าร้อยเอ็ดบาทยี่สิบเอ็ดสตางค์'209 );210 expect(convert(('-01654321.21' as unknown) as number)).toBe(211 'ลบหนึ่งล้านหกแสนห้าหมื่นสี่พันสามร้อยยี่สิบเอ็ดบาทยี่สิบเอ็ดสตางค์'212 );213 });214 it('should convert looping string numbers correctly', () => {215 for (let i = 100; i >= 0; i--) {216 const loopingNumber = Array(i)217 .fill('654321028761')218 .join('');219 const loopingText = Array(i)220 .fill(221 'ล้านหกแสนห้าหมื่นสี่พันสามร้อยยี่สิบเอ็ดล้านสองหมื่นแปดพันเจ็ดร้อยหกสิบเอ็ด'222 )223 .join('');224 expect(225 convert((`-1${loopingNumber}.21${555555}` as unknown) as number)226 ).toBe(`ลบหนึ่ง${loopingText}บาทยี่สิบเอ็ดสตางค์`);227 }228 });229 it('IEEE 754 Case String', () => {230 expect(convert(('283798.29' as unknown) as number)).toBe(231 'สองแสนแปดหมื่นสามพันเจ็ดร้อยเก้าสิบแปดบาทยี่สิบเก้าสตางค์'232 );233 expect(convert(('486293.57' as unknown) as number)).toBe(234 'สี่แสนแปดหมื่นหกพันสองร้อยเก้าสิบสามบาทห้าสิบเจ็ดสตางค์'235 );236 expect(convert(('552164.58' as unknown) as number)).toBe(237 'ห้าแสนห้าหมื่นสองพันหนึ่งร้อยหกสิบสี่บาทห้าสิบแปดสตางค์'238 );239 });240 it('IEEE 754 Case Small Number (<1000)', () => {241 expect(convert(0.29)).toBe('ยี่สิบเก้าสตางค์');242 expect(convert(553.57)).toBe('ห้าร้อยห้าสิบสามบาทห้าสิบเจ็ดสตางค์');243 expect(convert(790.58)).toBe('เจ็ดร้อยเก้าสิบบาทห้าสิบแปดสตางค์');244 });245 it('IEEE 754 Case Big Number (>100000)', () => {246 expect(convert(283798.29)).toBe(247 'สองแสนแปดหมื่นสามพันเจ็ดร้อยเก้าสิบแปดบาทยี่สิบเก้าสตางค์'248 );249 expect(convert(486293.57)).toBe(250 'สี่แสนแปดหมื่นหกพันสองร้อยเก้าสิบสามบาทห้าสิบเจ็ดสตางค์'251 );252 expect(convert(874552164.58)).toBe(253 'แปดร้อยเจ็ดสิบสี่ล้านห้าแสนห้าหมื่นสองพันหนึ่งร้อยหกสิบสี่บาทห้าสิบแปดสตางค์'254 );255 expect(convert(5143289600432.29)).toBe(256 'ห้าล้านหนึ่งแสนสี่หมื่นสามพันสองร้อยแปดสิบเก้าล้านหกแสนสี่ร้อยสามสิบสองบาทยี่สิบเก้าสตางค์'257 );258 });259 it('should convert spaces as 0', () => {260 expect(convert(('' as unknown) as number)).toBe('ศูนย์บาทถ้วน');261 expect(convert((' ' as unknown) as number)).toBe('ศูนย์บาทถ้วน');262 expect(convert((' ' as unknown) as number)).toBe('ศูนย์บาทถ้วน');263 });264 it('should convert number surrounding with spaces or zeros correctly', () => {265 const generateSpaceTest = (266 input: string,267 output: string,268 negativeOutput = ''269 ) => {270 const neg_output = negativeOutput || 'ลบ' + output;271 const int_tests = [272 [` ${input}`, output],273 [`${input} `, output],274 [` ${input} `, output],275 [` 0${input}`, output],276 [`0${input} `, output],277 [` 0${input} `, output],278 [` 00${input}`, output],279 [`00${input} `, output],280 [` 00${input} `, output],281 [` -${input}`, neg_output],282 [`-${input} `, neg_output],283 [` -${input} `, neg_output],284 [` -0${input}`, neg_output],285 [`-0${input} `, neg_output],286 [` -0${input} `, neg_output],287 [` -00${input}`, neg_output],288 [`-00${input} `, neg_output],289 [` -00${input} `, neg_output],290 ];291 const float_tests = [292 [` ${input}0`, output],293 [`${input}0 `, output],294 [` ${input}0 `, output],295 [` ${input}00`, output],296 [`${input}00 `, output],297 [` ${input}00 `, output],298 [` 0${input}0`, output],299 [`0${input}0 `, output],300 [` 0${input}0 `, output],301 [` 0${input}00`, output],302 [`0${input}00 `, output],303 [` 0${input}00 `, output],304 [` 00${input}0`, output],305 [`00${input}0 `, output],306 [` 00${input}0 `, output],307 [` 00${input}00`, output],308 [`00${input}00 `, output],309 [` 00${input}00 `, output],310 [` -${input}0`, neg_output],311 [`-${input}0 `, neg_output],312 [` -${input}0 `, neg_output],313 [` -${input}00`, neg_output],314 [`-${input}00 `, neg_output],315 [` -${input}00 `, neg_output],316 [` -0${input}0`, neg_output],317 [`-0${input}0 `, neg_output],318 [` -0${input}0 `, neg_output],319 [` -0${input}00`, neg_output],320 [`-0${input}00 `, neg_output],321 [` -0${input}00 `, neg_output],322 [` -00${input}0`, neg_output],323 [`-00${input}0 `, neg_output],324 [` -00${input}0 `, neg_output],325 [` -00${input}00`, neg_output],326 [`-00${input}00 `, neg_output],327 [` -00${input}00 `, neg_output],328 ];329 const tests = input.includes('.')330 ? int_tests.concat(float_tests)331 : int_tests;332 tests.forEach(([input, expected]) => {333 expect(convert((input as unknown) as number)).toBe(expected);334 });335 };336 // Normal Test337 generateSpaceTest('0', 'ศูนย์บาทถ้วน', 'ศูนย์บาทถ้วน'); // -0 is same as 0338 generateSpaceTest('0.0', 'ศูนย์บาทถ้วน', 'ศูนย์บาทถ้วน'); // -0.0 is same as 0.0339 generateSpaceTest('0.5', 'ห้าสิบสตางค์');340 generateSpaceTest('0.00', 'ศูนย์บาทถ้วน', 'ศูนย์บาทถ้วน'); // -0.00 is same as 0.00341 generateSpaceTest('0.50', 'ห้าสิบสตางค์');342 generateSpaceTest('0.55', 'ห้าสิบห้าสตางค์');343 generateSpaceTest('1', 'หนึ่งบาทถ้วน');344 generateSpaceTest('1.0', 'หนึ่งบาทถ้วน');345 generateSpaceTest('9.5', 'เก้าบาทห้าสิบสตางค์');346 generateSpaceTest('9.00', 'เก้าบาทถ้วน');347 generateSpaceTest('9.50', 'เก้าบาทห้าสิบสตางค์');348 generateSpaceTest('9.55', 'เก้าบาทห้าสิบห้าสตางค์');349 generateSpaceTest('11', 'สิบเอ็ดบาทถ้วน');350 generateSpaceTest('11.0', 'สิบเอ็ดบาทถ้วน');351 generateSpaceTest('11.5', 'สิบเอ็ดบาทห้าสิบสตางค์');352 generateSpaceTest('11.00', 'สิบเอ็ดบาทถ้วน');353 generateSpaceTest('11.50', 'สิบเอ็ดบาทห้าสิบสตางค์');354 generateSpaceTest('12.34', 'สิบสองบาทสามสิบสี่สตางค์');355 // From other tests356 generateSpaceTest(357 '123456789.999',358 'หนึ่งร้อยยี่สิบสามล้านสี่แสนห้าหมื่นหกพันเจ็ดร้อยแปดสิบเก้าบาทเก้าสิบเก้าสตางค์'359 );360 generateSpaceTest(361 '4123001998830750501',362 'สี่ล้านหนึ่งแสนสองหมื่นสามพันเอ็ดล้านเก้าแสนเก้าหมื่นแปดพันแปดร้อยสามสิบล้านเจ็ดแสนห้าหมื่นห้าร้อยเอ็ดบาทถ้วน'363 );364 generateSpaceTest(365 '4123001998830750501.21',366 'สี่ล้านหนึ่งแสนสองหมื่นสามพันเอ็ดล้านเก้าแสนเก้าหมื่นแปดพันแปดร้อยสามสิบล้านเจ็ดแสนห้าหมื่นห้าร้อยเอ็ดบาทยี่สิบเอ็ดสตางค์'367 );368 generateSpaceTest(369 '1654321.21',370 'หนึ่งล้านหกแสนห้าหมื่นสี่พันสามร้อยยี่สิบเอ็ดบาทยี่สิบเอ็ดสตางค์'371 );372 // IEEE Test373 generateSpaceTest('0.29', 'ยี่สิบเก้าสตางค์');374 generateSpaceTest('553.57', 'ห้าร้อยห้าสิบสามบาทห้าสิบเจ็ดสตางค์');375 generateSpaceTest('790.58', 'เจ็ดร้อยเก้าสิบบาทห้าสิบแปดสตางค์');376 generateSpaceTest(377 '283798.29',378 'สองแสนแปดหมื่นสามพันเจ็ดร้อยเก้าสิบแปดบาทยี่สิบเก้าสตางค์'379 );380 generateSpaceTest(381 '486293.57',382 'สี่แสนแปดหมื่นหกพันสองร้อยเก้าสิบสามบาทห้าสิบเจ็ดสตางค์'383 );384 generateSpaceTest(385 '874552164.58',386 'แปดร้อยเจ็ดสิบสี่ล้านห้าแสนห้าหมื่นสองพันหนึ่งร้อยหกสิบสี่บาทห้าสิบแปดสตางค์'387 );388 generateSpaceTest(389 '5143289600432.29',390 'ห้าล้านหนึ่งแสนสี่หมื่นสามพันสองร้อยแปดสิบเก้าล้านหกแสนสี่ร้อยสามสิบสองบาทยี่สิบเก้าสตางค์'391 );392 });393 // it('equals to value from other library (STRESS TEST)', () => {394 // for (let i = 1; i < 20000000; i += 1) {395 // expect(convert(i)).toEqual(bahtLatest(i));396 // expect(convert(i)).toEqual(thaiBahtText(i));397 // }398 // });...

Full Screen

Full Screen

state_current.py

Source:state_current.py Github

copy

Full Screen

...220 if k == 'EdgeFlag':221 print '%s\t\t__convert_boolean (&c->edgeFlag, v);' % (indent)222 dirtyVar = 'cb->edgeFlag'223 elif k == 'Normal':224 print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_NORMAL][0]), v);' % (indent)225 dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_NORMAL]'226 elif k == 'TexCoord':227 print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_TEX0 + i][0]), v);' % (indent)228 dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_TEX0 + i]'229 elif k == 'Color':230 print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_COLOR0][0]), v);' % (indent)231 dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_COLOR0]'232 elif k == 'Index':233 print '%s\t\tconvert(&(c->colorIndex), v);' % (indent)234 dirtyVar = 'cb->colorIndex'235 elif k == 'SecondaryColor':236 print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_COLOR1][0]), v);' % (indent)237 dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_COLOR1]'238 elif k == 'FogCoord':239 print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_FOG][0]), v);' % (indent)240 dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_FOG]'241 elif k == 'VertexAttrib':242 print '%s\t\tconvert(&(c->vertexAttrib[i][0]), v);' % (indent)243 dirtyVar = 'cb->vertexAttrib[i]'244 else:245 assert 0 # should never get here246 print '%s\t\tDIRTY(%s, nbitID);' % (indent, dirtyVar)247# if current_fns[k].has_key( 'array' ):248# print '%s\t\tDIRTY(cb->%s[i], nbitID);' % (indent,name)249# else:250# print '%s\t\tDIRTY(cb->%s, nbitID);' % (indent,name)251 print '%s\t\tDIRTY(cb->dirty, nbitID);' % indent252 print '%s\t}' % indent253 if current_fns[k].has_key( 'array' ):254 print '%s\t%s->ptr[i] = v;' % (indent, name )255 else:256 print '%s\t%s->ptr = v;' % (indent, name )257 if current_fns[k].has_key( 'array' ):258 print '\t}'259print '}'260print '''261void crStateCurrentRecoverNew(CRContext *g, CRCurrentStatePointers *current)262{263 const unsigned char *v;264 convert_func convert=NULL;265 CRCurrentState *c = &(g->current);266 CRStateBits *sb = GetCurrentBits();267 CRCurrentBits *cb = &(sb->current);268 static const GLfloat vertexAttrib_default[4] = {0.0f, 0.0f, 0.0f, 1.0f};269 GLvertexattrib_p *vertexAttrib = &(current->c.vertexAttrib);270 unsigned int i;271 CRbitvalue nbitID[CR_MAX_BITARRAY];272 /* silence warnings */273 (void) __convert_b1;274 (void) __convert_b2;275 (void) __convert_b3;276 (void) __convert_b4;277 (void) __convert_ui1;278 (void) __convert_ui2;279 (void) __convert_ui3;280 (void) __convert_ui4;281 (void) __convert_l1;282 (void) __convert_l2;283 (void) __convert_l3;284 (void) __convert_l4;285 (void) __convert_us1;286 (void) __convert_us2;287 (void) __convert_us3;288 (void) __convert_us4;289 (void) __convert_ub1;290 (void) __convert_ub2;291 (void) __convert_ub3;292 (void) __convert_ub4;293 (void) __convert_rescale_s1;294 (void) __convert_rescale_s2;295 (void) __convert_rescale_b1;296 (void) __convert_rescale_b2;297 (void) __convert_rescale_ui1;298 (void) __convert_rescale_ui2;299 (void) __convert_rescale_i1;300 (void) __convert_rescale_i2;301 (void) __convert_rescale_us1;302 (void) __convert_rescale_us2;303 (void) __convert_rescale_ub1;304 (void) __convert_rescale_ub2;305 (void) __convert_Ni1;306 (void) __convert_Ni2;307 (void) __convert_Ni3;308 (void) __convert_Ni4;309 (void) __convert_Nb1;310 (void) __convert_Nb2;311 (void) __convert_Nb3;312 (void) __convert_Nb4;313 (void) __convert_Nus1;314 (void) __convert_Nus2;315 (void) __convert_Nus3;316 (void) __convert_Nus4;317 (void) __convert_Nui1;318 (void) __convert_Nui2;319 (void) __convert_Nui3;320 (void) __convert_Nui4;321 (void) __convert_Ns1;322 (void) __convert_Ns2;323 (void) __convert_Ns3;324 (void) __convert_Ns4;325 (void) __convert_Nub1;326 (void) __convert_Nub2;327 (void) __convert_Nub3;328 (void) __convert_Nub4;329'''330for k in current_fns_new.keys():331 print '\t/* %s */' % k332 print '\tif (current->changed%s)' % k333 print '\t{'334 print '\t\tv=NULL;'335 name = '%s%s' % (k[:1].lower(),k[1:])336 indent = ""337 if current_fns_new[k].has_key( 'array' ):338 print '\t\tfor (i = 0 ; i < %s ; i++)' % current_fns_new[k]['array']339 print '\t\t{'340 indent += "\t\t"341 print '\t\tif (!(current->changed%s & (1 << i))) continue;' % k342 for type in current_fns_new[k]['types']:343 if type[0:1] == "N":344 normalized = 1345 type2 = type[1:]346 else:347 normalized = 0348 type2 = type349 for size in current_fns_new[k]['sizes']:350 ptr = '%s->%s%d' % (name, type, size )351 if current_fns_new[k].has_key( 'array' ):352 ptr += "[i]"353 print '#ifdef DEBUG_misha'354 print '%s\tif (%s)' % (indent, ptr)355 print '%s\t{' % (indent)356 print '%s\t\tuint32_t *pTst = (uint32_t*)(%s);' % (indent, ptr)357 print '%s\t\t--pTst;' % (indent)358 print '%s\t\tAssert((*pTst) == i);' % (indent)359 print '%s\t}' % (indent)360 print '#endif'361 print '%s\tif (v < %s)' % (indent, ptr)362 print '%s\t{' % indent363 print '%s\t\tv = %s;' % (indent, ptr)364 if (k == 'Color' or k == 'Normal' or k == 'SecondaryColor' or normalized) and type != 'f' and type != 'd' and type != 'l':365 print '%s\t\tconvert = (convert_func) __convert_rescale_%s%d;' % (indent,type,size)366 else:367 print '%s\t\tconvert = (convert_func) __convert_%s%d;' % (indent,type,size)368 print '%s\t}' % indent369 print ''370 print '%s\tif (v != NULL) {' % indent371 if current_fns_new[k].has_key( 'array' ):372 if k == 'TexCoord':373 print '%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_TEX0 + i], %s_default);' % (indent,name)374 else:375 print '%s\t\tCOPY_4V(c->%s[i], %s_default);' % (indent,name,name)376 else:377 if k == 'Normal':378 print '%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_NORMAL], %s_default);' % (indent,name)379 elif k == 'FogCoord':380 print '%s\t\tc->vertexAttrib[VERT_ATTRIB_FOG][0] = %s_default;' % (indent,name)381 elif k == 'Color':382 print '%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_COLOR0], %s_default);' % (indent,name)383 elif k == 'SecondaryColor':384 print '%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_COLOR1], %s_default);' % (indent,name)385 elif k == 'TexCoord':386 print '%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_TEX0], %s_default);' % (indent,name)387 elif k == 'Index':388 print '%s\t\tc->colorIndex = %s_default;' % (indent,name)389 elif k == 'EdgeFlag':390 print '%s\t\tc->edgeFlag = %s_default;' % (indent,name)391 else:392 print '%s\t\tc->%s = %s_default;' % (indent,name,name)393 if k == 'EdgeFlag':394 print '%s\t\t__convert_boolean (&c->edgeFlag, v);' % (indent)395 dirtyVar = 'cb->edgeFlag'396 elif k == 'Normal':397 print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_NORMAL][0]), v);' % (indent)398 dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_NORMAL]'399 elif k == 'TexCoord':400 print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_TEX0 + i][0]), v);' % (indent)401 dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_TEX0 + i]'402 elif k == 'Color':403 print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_COLOR0][0]), v);' % (indent)404 dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_COLOR0]'405 elif k == 'Index':406 print '%s\t\tconvert(&(c->colorIndex), v);' % (indent)407 dirtyVar = 'cb->colorIndex'408 elif k == 'SecondaryColor':409 print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_COLOR1][0]), v);' % (indent)410 dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_COLOR1]'411 elif k == 'FogCoord':412 print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_FOG][0]), v);' % (indent)413 dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_FOG]'414 elif k == 'VertexAttrib':415 print '%s\t\tconvert(&(c->vertexAttrib[i][0]), v);' % (indent)416 dirtyVar = 'cb->vertexAttrib[i]'417 else:418 assert 0 # should never get here419 print '%s\t\tDIRTY(%s, nbitID);' % (indent, dirtyVar)420# if current_fns_new[k].has_key( 'array' ):421# print '%s\t\tDIRTY(cb->%s[i], nbitID);' % (indent,name)422# else:423# print '%s\t\tDIRTY(cb->%s, nbitID);' % (indent,name)424 print '%s\t\tDIRTY(cb->dirty, nbitID);' % indent425 print '%s\t}' % indent426 if current_fns_new[k].has_key( 'array' ):427 print '%s\t%s->ptr[i] = v;' % (indent, name )428 else:429 print '%s\t%s->ptr = v;' % (indent, name )...

Full Screen

Full Screen

test_internals.py

Source:test_internals.py Github

copy

Full Screen

...119 r = s.convert_objects(convert_numeric=True)120 e = Series([False, True, False, False], dtype=bool)121 tm.assert_series_equal(r, e)122 # GH 10265123 def test_convert(self):124 # Tests: All to nans, coerce, true125 # Test coercion returns correct type126 s = Series(['a', 'b', 'c'])127 results = s._convert(datetime=True, coerce=True)128 expected = Series([lib.NaT] * 3)129 assert_series_equal(results, expected)130 results = s._convert(numeric=True, coerce=True)131 expected = Series([np.nan] * 3)132 assert_series_equal(results, expected)133 expected = Series([lib.NaT] * 3, dtype=np.dtype('m8[ns]'))134 results = s._convert(timedelta=True, coerce=True)135 assert_series_equal(results, expected)136 dt = datetime(2001, 1, 1, 0, 0)137 td = dt - datetime(2000, 1, 1, 0, 0)138 # Test coercion with mixed types139 s = Series(['a', '3.1415', dt, td])140 results = s._convert(datetime=True, coerce=True)141 expected = Series([lib.NaT, lib.NaT, dt, lib.NaT])142 assert_series_equal(results, expected)143 results = s._convert(numeric=True, coerce=True)144 expected = Series([nan, 3.1415, nan, nan])145 assert_series_equal(results, expected)146 results = s._convert(timedelta=True, coerce=True)147 expected = Series([lib.NaT, lib.NaT, lib.NaT, td],148 dtype=np.dtype('m8[ns]'))149 assert_series_equal(results, expected)150 # Test standard conversion returns original151 results = s._convert(datetime=True)152 assert_series_equal(results, s)153 results = s._convert(numeric=True)154 expected = Series([nan, 3.1415, nan, nan])155 assert_series_equal(results, expected)156 results = s._convert(timedelta=True)157 assert_series_equal(results, s)158 # test pass-through and non-conversion when other types selected159 s = Series(['1.0', '2.0', '3.0'])160 results = s._convert(datetime=True, numeric=True, timedelta=True)161 expected = Series([1.0, 2.0, 3.0])162 assert_series_equal(results, expected)163 results = s._convert(True, False, True)164 assert_series_equal(results, s)165 s = Series([datetime(2001, 1, 1, 0, 0), datetime(2001, 1, 1, 0, 0)],166 dtype='O')167 results = s._convert(datetime=True, numeric=True, timedelta=True)168 expected = Series([datetime(2001, 1, 1, 0, 0), datetime(2001, 1, 1, 0,169 0)])170 assert_series_equal(results, expected)171 results = s._convert(datetime=False, numeric=True, timedelta=True)172 assert_series_equal(results, s)173 td = datetime(2001, 1, 1, 0, 0) - datetime(2000, 1, 1, 0, 0)174 s = Series([td, td], dtype='O')175 results = s._convert(datetime=True, numeric=True, timedelta=True)176 expected = Series([td, td])177 assert_series_equal(results, expected)178 results = s._convert(True, True, False)179 assert_series_equal(results, s)180 s = Series([1., 2, 3], index=['a', 'b', 'c'])181 result = s._convert(numeric=True)182 assert_series_equal(result, s)183 # force numeric conversion184 r = s.copy().astype('O')185 r['a'] = '1'186 result = r._convert(numeric=True)187 assert_series_equal(result, s)188 r = s.copy().astype('O')189 r['a'] = '1.'190 result = r._convert(numeric=True)191 assert_series_equal(result, s)192 r = s.copy().astype('O')193 r['a'] = 'garbled'194 result = r._convert(numeric=True)195 expected = s.copy()196 expected['a'] = nan197 assert_series_equal(result, expected)198 # GH 4119, not converting a mixed type (e.g.floats and object)199 s = Series([1, 'na', 3, 4])200 result = s._convert(datetime=True, numeric=True)201 expected = Series([1, nan, 3, 4])202 assert_series_equal(result, expected)203 s = Series([1, '', 3, 4])204 result = s._convert(datetime=True, numeric=True)205 assert_series_equal(result, expected)206 # dates207 s = Series([datetime(2001, 1, 1, 0, 0), datetime(2001, 1, 2, 0, 0),208 datetime(2001, 1, 3, 0, 0)])209 s2 = Series([datetime(2001, 1, 1, 0, 0), datetime(2001, 1, 2, 0, 0),210 datetime(2001, 1, 3, 0, 0), 'foo', 1.0, 1,211 Timestamp('20010104'), '20010105'], dtype='O')212 result = s._convert(datetime=True)213 expected = Series([Timestamp('20010101'), Timestamp('20010102'),214 Timestamp('20010103')], dtype='M8[ns]')215 assert_series_equal(result, expected)216 result = s._convert(datetime=True, coerce=True)217 assert_series_equal(result, expected)218 expected = Series([Timestamp('20010101'), Timestamp('20010102'),219 Timestamp('20010103'), lib.NaT, lib.NaT, lib.NaT,220 Timestamp('20010104'), Timestamp('20010105')],221 dtype='M8[ns]')222 result = s2._convert(datetime=True, numeric=False, timedelta=False,223 coerce=True)224 assert_series_equal(result, expected)225 result = s2._convert(datetime=True, coerce=True)226 assert_series_equal(result, expected)227 s = Series(['foo', 'bar', 1, 1.0], dtype='O')228 result = s._convert(datetime=True, coerce=True)229 expected = Series([lib.NaT] * 2 + [Timestamp(1)] * 2)230 assert_series_equal(result, expected)231 # preserver if non-object232 s = Series([1], dtype='float32')233 result = s._convert(datetime=True, coerce=True)234 assert_series_equal(result, s)235 # r = s.copy()236 # r[0] = np.nan237 # result = r._convert(convert_dates=True,convert_numeric=False)238 # assert result.dtype == 'M8[ns]'239 # dateutil parses some single letters into today's value as a date240 expected = Series([lib.NaT])241 for x in 'abcdefghijklmnopqrstuvwxyz':242 s = Series([x])243 result = s._convert(datetime=True, coerce=True)244 assert_series_equal(result, expected)245 s = Series([x.upper()])246 result = s._convert(datetime=True, coerce=True)247 assert_series_equal(result, expected)248 def test_convert_no_arg_error(self):249 s = Series(['1.0', '2'])250 pytest.raises(ValueError, s._convert)251 def test_convert_preserve_bool(self):252 s = Series([1, True, 3, 5], dtype=object)253 r = s._convert(datetime=True, numeric=True)254 e = Series([1, 1, 3, 5], dtype='i8')255 tm.assert_series_equal(r, e)256 def test_convert_preserve_all_bool(self):257 s = Series([False, True, False, False], dtype=object)258 r = s._convert(datetime=True, numeric=True)259 e = Series([False, True, False, False], dtype=bool)...

Full Screen

Full Screen

basic.js

Source:basic.js Github

copy

Full Screen

...106assert.deepEqual(convert["xyz"]["lab"](val), convert.xyz2lab(val));107val = [69, -48, 44];108assert.deepEqual(convert["lab"]["xyz"](val), [25, 39, 15]);109// converter110var converter = convert();111var vals = [140, 200, 100];112converter.rgb(140, 200, 100);113assert.deepEqual(converter.hsl(), convert.rgb2hsl(vals));114assert.deepEqual(converter.hsv(), convert.rgb2hsv(vals));115assert.deepEqual(converter.cmyk(), convert.rgb2cmyk(vals));116assert.deepEqual(converter.rgb(), vals);117assert.deepEqual(converter.rgb([255, 228, 196]).keyword(), "bisque");118vals = [96, 48, 59];119converter.hsl(vals);120assert.deepEqual(converter.rgb(), convert.hsl2rgb(vals));121assert.deepEqual(converter.hsv(), convert.hsl2hsv(vals));122assert.deepEqual(converter.cmyk(), convert.hsl2cmyk(vals));123assert.deepEqual(converter.keyword(), convert.hsl2keyword(vals));124// hwb...

Full Screen

Full Screen

DataField.js

Source:DataField.js Github

copy

Full Screen

1/*!2 * Ext JS Library 3.2.23 * Copyright(c) 2006-2010 Ext JS, Inc.4 * licensing@extjs.com5 * http://www.extjs.com/license6 */7Ext.test.session.addTest('Ext.data.Field', {8 name: 'Test data field creation',9 10 setUp: function(){11 this.t = Ext.data.Types;12 this.st = Ext.data.SortTypes;13 },14 15 tearDown: function(){16 delete this.t;17 delete this.st;18 },19 20 test_alias: function(){21 var f;22 23 f = new Ext.data.Field({type: null});24 Y.Assert.areEqual(this.t.AUTO, f.type, 'Test empty alias');25 f = new Ext.data.Field({type: 'auto'});26 Y.Assert.areEqual(this.t.AUTO, f.type, 'Test auto alias');27 28 f = new Ext.data.Field({type: 'int'});29 Y.Assert.areEqual(this.t.INT, f.type, 'Test int alias');30 f = new Ext.data.Field({type: 'integer'});31 Y.Assert.areEqual(this.t.INT, f.type, 'Test integer alias');32 33 f = new Ext.data.Field({type: 'float'});34 Y.Assert.areEqual(this.t.FLOAT, f.type, 'Test float alias');35 f = new Ext.data.Field({type: 'number'});36 Y.Assert.areEqual(this.t.FLOAT, f.type, 'Test number alias');37 38 f = new Ext.data.Field({type: 'bool'});39 Y.Assert.areEqual(this.t.BOOL, f.type, 'Test bool alias');40 f = new Ext.data.Field({type: 'boolean'});41 Y.Assert.areEqual(this.t.BOOL, f.type, 'Test boolean alias');42 43 f = new Ext.data.Field({type: 'string'});44 Y.Assert.areEqual(this.t.STRING, f.type, 'Test string alias');45 46 f = new Ext.data.Field({type: 'date'});47 Y.Assert.areEqual(this.t.DATE, f.type, 'Test date alias');48 },49 50 test_type: function(){51 var f;52 53 f = new Ext.data.Field({type: this.t.INT});54 Y.Assert.areEqual(this.t.INT, f.type, 'Test int type');55 56 f = new Ext.data.Field({type: this.t.AUTO});57 Y.Assert.areEqual(this.t.AUTO, f.type, 'Test auto type');58 59 f = new Ext.data.Field({type: this.t.STRING});60 Y.Assert.areEqual(this.t.STRING, f.type, 'Test string type');61 },62 63 test_sortType: function(){64 var f,65 s1 = function(v){66 return v * v; 67 },68 s2 = function(v){69 return Math.sqrt(v);70 };71 72 f = new Ext.data.Field({type: 'auto'});73 Y.Assert.areEqual(this.st.none, f.sortType, 'Test sort type defaults for auto');74 75 f = new Ext.data.Field({type: 'int'});76 Y.Assert.areEqual(this.st.none, f.sortType, 'Test sort type defaults for int');77 78 f = new Ext.data.Field({type: 'float'});79 Y.Assert.areEqual(this.st.none, f.sortType, 'Test sort type defaults for float');80 81 f = new Ext.data.Field({type: 'bool'});82 Y.Assert.areEqual(this.st.none, f.sortType, 'Test sort type defaults for bool');83 84 f = new Ext.data.Field({type: 'string'});85 Y.Assert.areEqual(this.st.asUCString, f.sortType, 'Test sort type defaults for string');86 87 f = new Ext.data.Field({type: 'date'});88 Y.Assert.areEqual(this.st.asDate, f.sortType, 'Test sort type defaults for date');89 90 f = new Ext.data.Field({91 type: 'auto',92 sortType: 'asDate'93 });94 Y.Assert.areEqual(this.st.asDate, f.sortType, 'Test with custom string sortType');95 96 f = new Ext.data.Field({97 type: 'int',98 sortType: s199 });100 Y.Assert.areEqual(s1, f.sortType, 'Test with custom function sortType');101 102 f = new Ext.data.Field({103 type: 'date',104 sortType: s2105 });106 Y.Assert.areEqual(s2, f.sortType, 'Test with another custom function sortType');107 },108 109 test_convert: function(){110 var f,111 c1 = function(v){112 return v / 3;113 },114 c2 = function(v){115 return v * 4; 116 };117 118 f = new Ext.data.Field({type: 'auto'});119 Y.Assert.areEqual(this.t.AUTO.convert, f.convert, 'Test convert for auto');120 121 f = new Ext.data.Field({type: 'int'});122 Y.Assert.areEqual(this.t.INT.convert, f.convert, 'Test convert for int');123 124 f = new Ext.data.Field({type: 'float'});125 Y.Assert.areEqual(this.t.FLOAT.convert, f.convert, 'Test convert for float');126 127 f = new Ext.data.Field({type: 'bool'});128 Y.Assert.areEqual(this.t.BOOL.convert, f.convert, 'Test convert for bool');129 130 f = new Ext.data.Field({type: 'string'});131 Y.Assert.areEqual(this.t.STRING.convert, f.convert, 'Test convert for string');132 133 f = new Ext.data.Field({type: 'date'});134 Y.Assert.areEqual(this.t.DATE.convert, f.convert, 'Test convert for date');135 136 f = new Ext.data.Field({137 type: 'int',138 convert: c1139 });140 Y.Assert.areEqual(c1, f.convert, 'Test with custom function convert');141 142 f = new Ext.data.Field({143 type: 'date',144 convert: c2145 });146 Y.Assert.areEqual(c2, f.convert, 'Test with another custom function convert');147 }...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1import React from 'react';2import { storiesOf } from '@storybook/react';3import Basic from './Basic';4import BasicControlled from './BasicControlled';5import BasicContentState from './BasicContentState';6import ReadOnly from './ReadOnly';7import SpellCheck from './SpellCheck';8import HashTag from './HashTag';9import Mention from './Mention';10import I18n from './I18n';11import ToolbarHidden from './ToolbarHidden';12import ImageUpload from './ImageUpload';13import Embeddable from "./Embeddable";14import ImageDataURI from './ImageDataURI';15import SelectedOptions from './SelectedOptions';16import FloatingToolbar from './FloatingToolbar';17import CustomToolbar from './CustomToolbar';18import ConvertToHTML from './ConvertToHTML';19import ConvertFromHTML from './ConvertFromHTML';20import ConvertToMarkdown from './ConvertToMarkdown';21import FocusBlurCallbacks from './FocusBlurCallbacks';22import ConvertFromRawDraftContent from './ConvertFromRawDraftContent';23import ConvertToRawDraftContent from './ConvertToRawDraftContent';24import './styles.css';25storiesOf('Basic - uncontrolled', module).add('story', () => <Basic />);26storiesOf('Basic - controlled', module).add('story', () => <BasicControlled />);27storiesOf('Basic - content state', module).add('story', () => <BasicContentState />);28storiesOf('ReadOnly', module).add('story', () => <ReadOnly />);29storiesOf('SpellCheck', module).add('story', () => <SpellCheck />);30storiesOf('I18n', module).add('story', () => <I18n />);31storiesOf('ToolbarHidden', module).add('story', () => <ToolbarHidden />);32storiesOf('FocusBlurCallbacks', module).add('story', () => <FocusBlurCallbacks />);33storiesOf('HashTag', module).add('story', () => <HashTag />);34storiesOf('Mention', module).add('story', () => <Mention />);35storiesOf('SelectedOptions', module).add('story', () => <SelectedOptions />);36storiesOf('CustomToolbar', module).add('story', () => <CustomToolbar />);37storiesOf('FloatingToolbar', module).add('story', () => <FloatingToolbar />);38storiesOf('ImageUpload and Alt attribute', module).add('story', () => <ImageUpload />);39storiesOf('Image as data URI and preview', module).add('story', () => <ImageDataURI />);40storiesOf("Embeddable with Callback", module).add("story", () => <Embeddable />);41storiesOf('ConvertFromRawDraftContent', module).add('story', () => <ConvertFromRawDraftContent />);42storiesOf('ConvertToRawDraftContent', module).add('story', () => <ConvertToRawDraftContent />);43storiesOf('ConvertToHTML', module).add('story', () => <ConvertToHTML />);44storiesOf('ConvertFromHTML', module).add('story', () => <ConvertFromHTML />);...

Full Screen

Full Screen

config.py

Source:config.py Github

copy

Full Screen

1# Copyright 2016 The TensorFlow Authors. All Rights Reserved.2#3# Licensed under the Apache License, Version 2.0 (the "License");4# you may not use this file except in compliance with the License.5# You may obtain a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS,11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12# See the License for the specific language governing permissions and13# limitations under the License.14# ==============================================================================15"""Global configuration."""16from __future__ import absolute_import17from __future__ import division18from __future__ import print_function19from tensorflow.python.autograph.core import config_lib20Action = config_lib.Action21Convert = config_lib.Convert22DoNotConvert = config_lib.DoNotConvert23# This list is evaluated in order and stops at the first rule that tests True24# for a definitely_convert of definitely_bypass call.25CONVERSION_RULES = (26 # Known packages27 Convert('tensorflow.python.training.experimental'),28 # Builtin modules29 DoNotConvert('collections'),30 DoNotConvert('copy'),31 DoNotConvert('cProfile'),32 DoNotConvert('inspect'),33 DoNotConvert('ipdb'),34 DoNotConvert('linecache'),35 DoNotConvert('mock'),36 DoNotConvert('pathlib'),37 DoNotConvert('pdb'),38 DoNotConvert('posixpath'),39 DoNotConvert('pstats'),40 DoNotConvert('re'),41 DoNotConvert('threading'),42 DoNotConvert('urllib'),43 # Known libraries44 DoNotConvert('matplotlib'),45 DoNotConvert('numpy'),46 DoNotConvert('pandas'),47 DoNotConvert('tensorflow'),48 DoNotConvert('PIL'),49 # TODO(b/133417201): Remove.50 DoNotConvert('tensorflow_probability'),51 # TODO(b/133842282): Remove.52 DoNotConvert('tensorflow_datasets.core'),...

Full Screen

Full Screen

5-2.py

Source:5-2.py Github

copy

Full Screen

1def convertToBinary(x):2 digit, tmp, res = 0, 1, 03 while x > 0:4 if x >= tmp:5 res += 1 / pow(10, digit)6 x -= tmp7 digit += 18 tmp /= 29 if digit > 32:10 return "ERROR"11 12 return res13def convertToBinary2(x):14 if x == 1 or x == 0:15 return str(x)16 res = "0."17 r = 118 while x > 0:19 if len(res) > 34:20 return "ERROR"21 r /= 222 if x >= r:23 res += "1"24 x -= r25 else:26 res += "0"27 return res28if __name__ == '__main__':29 print(convertToBinary(1))30 print(convertToBinary(0))31 print(convertToBinary(0.5))32 print(convertToBinary(0.25))33 print(convertToBinary(0.75))34 print(convertToBinary(0.3))35 print(convertToBinary2(1))36 print(convertToBinary2(0))37 print(convertToBinary2(0.5))38 print(convertToBinary2(0.25))39 print(convertToBinary2(0.75))...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { addDecorator } from '@storybook/react';2import { convert } from 'storybook-root-decorator';3addDecorator(convert);4import { addDecorator } from '@storybook/react';5import { convert } from 'storybook-root-decorator';6addDecorator(convert);7import { addDecorator } from '@storybook/react';8import { convert } from 'storybook-root-decorator';9addDecorator(convert);10import { addDecorator } from '@storybook/react';11import { convert } from 'storybook-root-decorator';12addDecorator(convert);13import { addDecorator } from '@storybook/react';14import { convert } from 'storybook-root-decorator';15addDecorator(convert);16import { addDecorator } from '@storybook/react';17import { convert } from 'storybook-root-decorator';18addDecorator(convert);19import { addDecorator } from '@storybook/react';20import { convert } from 'storybook-root-decorator';21addDecorator(convert);22import { addDecorator } from '@storybook/react';23import { convert } from 'storybook-root-decorator';24addDecorator(convert);25import { addDecorator } from '@storybook/react';26import { convert } from 'storybook-root-decorator';27addDecorator(convert);28import { addDecorator } from '@storybook/react';29import { convert } from 'storybook-root-decorator';30addDecorator(convert);31import { addDecorator } from '@storybook/react';32import { convert } from 'storybook-root-decorator';33addDecorator(convert);34import { addDecorator } from '@storybook/react';35import { convert } from '

Full Screen

Using AI Code Generation

copy

Full Screen

1import { convert } from 'storybook-root-provider';2const result = convert('Hello World');3import { convert } from 'storybook-root-provider';4describe('storybook-root-provider', () => {5 it('should convert string to lowercase', () => {6 const result = convert('Hello World');7 expect(result).toBe('hello-world');8 });9});10import { convert } from 'storybook-root-provider';11describe('storybook-root-provider', () => {12 it('should convert string to lowercase', () => {13 const result = convert('Hello World');14 expect(result).toBe('hello-world');15 });16});17import { convert } from 'storybook-root-provider';18const result = convert('Hello World');19import { convert } from 'storybook-root-provider';20describe('storybook-root-provider', () => {21 it('should convert string to lowercase', () => {22 const result = convert('Hello World');23 expect(result).toBe('hello-world');24 });25});26import { convert } from 'storybook-root-provider';27describe('storybook-root-provider', () => {28 it('should convert string to lowercase', () => {29 const result = convert('Hello World');30 expect(result).toBe('hello-world');31 });32});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { convert } from 'storybook-root/convert';2const converted = convert('Hello World');3console.log(converted);4import { convert } from 'storybook-root/convert';5const converted = convert('Hello World');6console.log(converted);7import { convert } from 'storybook-root/convert';8const converted = convert('Hello World');9console.log(converted);10import { convert } from 'storybook-root/convert';11const converted = convert('Hello World');12console.log(converted);13import { convert } from 'storybook-root/convert';14const converted = convert('Hello World');15console.log(converted);16import { convert } from 'storybook-root/convert';17const converted = convert('Hello World');18console.log(converted);19import { convert } from 'storybook-root/convert';20const converted = convert('Hello World');21console.log(converted);22import { convert } from 'storybook-root/convert';23const converted = convert('Hello World');24console.log(converted);25import { convert } from 'storybook-root/convert';26const converted = convert('Hello World');27console.log(converted);28import { convert } from 'storybook-root/convert';29const converted = convert('Hello World');30console.log(converted);

Full Screen

Using AI Code Generation

copy

Full Screen

1import { convert } from 'storybook-root'2const converted = convert('some text')3console.log(converted)4import { addDecorator } from '@storybook/react'5import { convert } from 'storybook-root'6addDecorator(convert)7import { addDecorator } from '@storybook/react'8import { convert } from 'storybook-root'9addDecorator(convert)10import { addDecorator } from '@storybook/react'11import { convert } from 'storybook-root'12addDecorator(convert)13import { addDecorator } from '@storybook/react'14import { convert } from 'storybook-root'15addDecorator(convert)16import { addDecorator } from '@storybook/react'17import { convert } from 'storybook-root'18addDecorator(convert)19import { addDecorator } from '@storybook/react'20import { convert } from 'storybook-root'21addDecorator(convert)22import { addDecorator } from '@storybook/react'23import { convert } from 'storybook-root'24addDecorator(convert)25import { addDecorator } from '@storybook/react'26import { convert } from 'storybook-root'27addDecorator(convert)28import { addDecorator } from '@storybook/react'29import { convert } from 'storybook-root'30addDecorator(convert)31import { addDecorator } from '@storybook/react'32import { convert } from 'storybook-root'33addDecorator(convert)34import

Full Screen

Using AI Code Generation

copy

Full Screen

1const convert = require('storybook-root').convert;2convert({src: './src', dest: './dist'});3"scripts": {4 }5convert({src: './src', dest: './dist'});6convert({src: './src', dest: './dist', template: './custom-template.js'});7module.exports = function({src, dest}) {8 return `import { storiesOf, addDecorator } from '@storybook/react';9import { withKnobs } from '@storybook/addon-knobs';10import { withInfo } from '@storybook/addon-info';11import { withA11y } from '@storybook/addon-a11y';12import { withBackgrounds } from '@storybook/addon-backgrounds';13import { withViewport } from '@storybook/addon-viewport';14import { withReadme } from 'storybook-readme';15import { withDocs } from 'storybook-readme';16import * as stories from ${src};17const storiesOf = storiesOf('Components', module)18 .addDecorator(withKnobs)19 .addDecorator(withInfo)20 .addDecorator(withA11y)21 .addDecorator(withBackgrounds)22 .addDecorator(withViewport)23 .addDecorator(withReadme)24 .addDecorator(withDocs);25storiesOf.add('Button', stories.Button);26storiesOf.add('Input', stories.Input);27storiesOf.add('Select', stories.Select);28storiesOf.add('Textarea', stories.Textarea);`;29};

Full Screen

Using AI Code Generation

copy

Full Screen

1import { convert } from 'storybook-root';2const converted = convert('my-storybook');3console.log(converted);4import { convert } from 'storybook-root';5const convertRoot = convert();6const converted = convertRoot('my-storybook');7console.log(converted);8import { convert } from 'storybook-root';9const convertRoot = convert();10const converted = convertRoot('my-storybook');11console.log(converted);12import { convert } from 'storybook-root';13const convertRoot = convert();14const converted = convertRoot('my-storybook');15console.log(converted);16import { convert } from 'storybook-root';17const convertRoot = convert();18const converted = convertRoot('my-storybook');19console.log(converted);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run storybook-root automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful