Best JavaScript code snippet using storybook-root
index.test.ts
Source:index.test.ts
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 // });...
state_current.py
Source:state_current.py
...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 )...
test_internals.py
Source:test_internals.py
...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)...
basic.js
Source:basic.js
...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...
DataField.js
Source:DataField.js
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 }...
index.js
Source:index.js
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 />);...
config.py
Source:config.py
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'),...
5-2.py
Source:5-2.py
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))...
Using AI Code Generation
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 '
Using AI Code Generation
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});
Using AI Code Generation
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);
Using AI Code Generation
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
Using AI Code Generation
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};
Using AI Code Generation
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);
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!