From e5413b5d4b348c172bfba7a173f8d7f9c3bc97dd Mon Sep 17 00:00:00 2001 From: Mohamadamin Karami Date: Fri, 4 Feb 2022 05:50:51 +0330 Subject: [PATCH 1/3] Fix: implement curcularBuffer type checks --- .../utils/circular-buffer/docs/types/test.ts | 69 +++++++++++++------ 1 file changed, 49 insertions(+), 20 deletions(-) diff --git a/lib/node_modules/@stdlib/utils/circular-buffer/docs/types/test.ts b/lib/node_modules/@stdlib/utils/circular-buffer/docs/types/test.ts index 7f4759e23f87..7ce5d048dfe8 100644 --- a/lib/node_modules/@stdlib/utils/circular-buffer/docs/types/test.ts +++ b/lib/node_modules/@stdlib/utils/circular-buffer/docs/types/test.ts @@ -1,35 +1,64 @@ /* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * @license Apache-2.0 + * + * Copyright (c) 2021 The Stdlib Authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* tslint:disable:no-unused-expression */ -import CircularBuffer = require( './index' ); - +import CircularBuffer = require("./index"); // TESTS // // The function returns a circular buffer instance... { - new CircularBuffer( 3 ); // $ExpectType CircularBuffer + new CircularBuffer(3); // $ExpectType CircularBuffer + new CircularBuffer([2, 3]); // $ExpectType CircularBuffer +} + +// The functions or fields of instance should be ok +{ + const buf = new CircularBuffer(3); // $ExpectType CircularBuffer + buf.push("foo"); + let circularBuf: CircularBuffer; + let numberType: number; + let booleanType: boolean; + let stringType: string; + let arrayType: any[]; + + numberType = buf.count; + numberType = buf.length; + booleanType = buf.full; + circularBuf = buf.clear(); + stringType = buf.toJSON(); + arrayType = buf.toArray(); } // The compiler throws an error if the constructor function is provided an invalid number of arguments... { new CircularBuffer(); // $ExpectError - new CircularBuffer( 3, 4 ); // $ExpectError + new CircularBuffer(3, 4); // $ExpectError +} + +// The compiler throws an error if the constructor function is provided an invalid type of argument... +{ + new CircularBuffer("invalidType"); // $ExpectError + new CircularBuffer(12.2); // $ExpectError + new CircularBuffer({}); // $ExpectError + new CircularBuffer(true); // $ExpectError + new CircularBuffer(null); // $ExpectError + new CircularBuffer(undefined); // $ExpectError + new CircularBuffer(new Date()); // $ExpectError } From 09cd55daf327c4dd6c759c64f7d801b48f744c57 Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 3 Feb 2022 19:22:52 -0800 Subject: [PATCH 2/3] Update description --- .../@stdlib/utils/circular-buffer/docs/types/test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/utils/circular-buffer/docs/types/test.ts b/lib/node_modules/@stdlib/utils/circular-buffer/docs/types/test.ts index 7ce5d048dfe8..5065607671a8 100644 --- a/lib/node_modules/@stdlib/utils/circular-buffer/docs/types/test.ts +++ b/lib/node_modules/@stdlib/utils/circular-buffer/docs/types/test.ts @@ -52,7 +52,7 @@ import CircularBuffer = require("./index"); new CircularBuffer(3, 4); // $ExpectError } -// The compiler throws an error if the constructor function is provided an invalid type of argument... +// The compiler throws an error if the constructor is provided an invalid argument type... { new CircularBuffer("invalidType"); // $ExpectError new CircularBuffer(12.2); // $ExpectError From 9b8037df44f6a23881f0b0bada93567dbe4776c0 Mon Sep 17 00:00:00 2001 From: Mohamadamin Karami <91487044+mohamadaminkarami@users.noreply.github.com> Date: Fri, 4 Feb 2022 12:03:53 +0330 Subject: [PATCH 3/3] Fix: Fix coding styles --- .../utils/circular-buffer/docs/types/test.ts | 59 ++++++++++--------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/lib/node_modules/@stdlib/utils/circular-buffer/docs/types/test.ts b/lib/node_modules/@stdlib/utils/circular-buffer/docs/types/test.ts index 5065607671a8..d03dcf1cbf59 100644 --- a/lib/node_modules/@stdlib/utils/circular-buffer/docs/types/test.ts +++ b/lib/node_modules/@stdlib/utils/circular-buffer/docs/types/test.ts @@ -1,37 +1,38 @@ /* - * @license Apache-2.0 - * - * Copyright (c) 2021 The Stdlib Authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* @license Apache-2.0 +* +* Copyright (c) 2021 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ /* tslint:disable:no-unused-expression */ -import CircularBuffer = require("./index"); +import CircularBuffer = require( './index' ); + // TESTS // // The function returns a circular buffer instance... { - new CircularBuffer(3); // $ExpectType CircularBuffer - new CircularBuffer([2, 3]); // $ExpectType CircularBuffer + new CircularBuffer( 3 ); // $ExpectType CircularBuffer + new CircularBuffer( [2, 3] ); // $ExpectType CircularBuffer } // The functions or fields of instance should be ok { - const buf = new CircularBuffer(3); // $ExpectType CircularBuffer - buf.push("foo"); + const buf = new CircularBuffer( 3 ); // $ExpectType CircularBuffer + buf.push( 'foo' ); let circularBuf: CircularBuffer; let numberType: number; let booleanType: boolean; @@ -49,16 +50,16 @@ import CircularBuffer = require("./index"); // The compiler throws an error if the constructor function is provided an invalid number of arguments... { new CircularBuffer(); // $ExpectError - new CircularBuffer(3, 4); // $ExpectError + new CircularBuffer( 3, 4 ); // $ExpectError } // The compiler throws an error if the constructor is provided an invalid argument type... { - new CircularBuffer("invalidType"); // $ExpectError - new CircularBuffer(12.2); // $ExpectError - new CircularBuffer({}); // $ExpectError - new CircularBuffer(true); // $ExpectError - new CircularBuffer(null); // $ExpectError - new CircularBuffer(undefined); // $ExpectError - new CircularBuffer(new Date()); // $ExpectError + new CircularBuffer( 'invalidType' ); // $ExpectError + new CircularBuffer( 12.2 ); // $ExpectError + new CircularBuffer( {} ); // $ExpectError + new CircularBuffer( true ); // $ExpectError + new CircularBuffer( null ); // $ExpectError + new CircularBuffer( undefined ); // $ExpectError + new CircularBuffer( new Date() ); // $ExpectError }