提交 0c909097 编写于 作者: 杜庆泉's avatar 杜庆泉

add some case

上级 a601045c
...@@ -7,6 +7,16 @@ type UserJSON={ ...@@ -7,6 +7,16 @@ type UserJSON={
name:string|null; name:string|null;
} }
/**
* 测试属性名为 原生关键字的场景
*/
type UserWithKeyWord={
class:string;
abstract:number;
is:boolean;
}
export function testJSON() : Result { export function testJSON() : Result {
return describe("JSON", () => { return describe("JSON", () => {
test('parse', () => { test('parse', () => {
...@@ -80,7 +90,10 @@ export function testJSON() : Result { ...@@ -80,7 +90,10 @@ export function testJSON() : Result {
// p: 10, // p: 10,
// }); // });
expect(JSON.parse('{}')!).toEqual({}); expect(JSON.parse('{}')!).toEqual({});
let userKeyWord = JSON.parse<UserWithKeyWord>('{"is":false,"class":"classOne","abstract":12}')
expect(userKeyWord!.class).toEqual("classOne");
// TODO 不支持boolean、string,js端需抹平 // TODO 不支持boolean、string,js端需抹平
// expect(JSON.parse('true')!).toEqual(true); // expect(JSON.parse('true')!).toEqual(true);
// expect(JSON.parse('"foo"')!).toEqual("foo"); // expect(JSON.parse('"foo"')!).toEqual("foo");
......
...@@ -22,9 +22,9 @@ export function testKeyWord(): Result { ...@@ -22,9 +22,9 @@ export function testKeyWord(): Result {
test('typeof', () => { test('typeof', () => {
let new1 = new User() let new1 = new User()
expect(typeof(new1)).toEqual('object') expect(typeof(new1)).toEqual('object')
expect(typeof(123456.789)).toEqual('number') expect(typeof(123456.789)).toEqual("Double")
//expect(typeof(789778979798797987979)).toEqual('number') //expect(typeof(789778979798797987979)).toEqual('number')
expect(typeof(0.0)).toEqual('number') expect(typeof(0.0)).toEqual("Double")
expect(typeof("hello world")).toEqual('string') expect(typeof("hello world")).toEqual('string')
expect(typeof([1,2,3])).toEqual('object') expect(typeof([1,2,3])).toEqual('object')
expect(typeof(new Array<any>())).toEqual('object') expect(typeof(new Array<any>())).toEqual('object')
......
...@@ -62,6 +62,12 @@ export function testNumber(): Result { ...@@ -62,6 +62,12 @@ export function testNumber(): Result {
expect(isFinite(910)).toEqual(true); expect(isFinite(910)).toEqual(true);
expect(isFinite(0)).toEqual(true); expect(isFinite(0)).toEqual(true);
}) })
test('isInteger', () => {
expect(Number.isInteger(12.0)).toEqual(true);
expect(Number.isInteger(12.01)).toEqual(false);
expect(Number.isInteger(-213123112.01)).toEqual(false);
expect(Number.isInteger(-213123112)).toEqual(true);
})
test('isNaN', () => { test('isNaN', () => {
expect(isNaN(0)).toEqual(false); expect(isNaN(0)).toEqual(false);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册