Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions lib/node_modules/@stdlib/ndarray/base/assign/test/test.0d.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 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.
*/

'use strict';

// MODULES //

var tape = require( 'tape' );
var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' );
var isSameAccessorArray = require( '@stdlib/assert/is-same-accessor-array' );
var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
var Float64Array = require( '@stdlib/array/float64' );
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
var ndarray = require( '@stdlib/ndarray/ctor' );
var assign = require( './../lib' );


// TESTS //

tape( 'main export is a function', function test( t ) {
t.ok( true, __filename );
t.strictEqual( typeof assign, 'function', 'main export is a function' );
t.end();
});

tape( 'the function assigns elements from n 0-dimensional input ndarray to an output ndarray', function test( t ) {
var expected;
var x;
var y;

x = scalar2ndarray( 10.0, {
'dtype': 'float64'
});
y = scalar2ndarray( 0.0, {
'dtype': 'float64'
});

assign( [ x, y ] );

expected = new Float64Array( [ 10.0 ] );
t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' );

t.end();
});

tape( 'the function assigns elements from n 0-dimensional input ndarray to an output ndarray (accessors)', function test( t ) {
var x;
var y;

x = ndarray( 'generic', toAccessorArray( [ 1.0 ] ), [], [ 0 ], 0, 'row-major' );
y = ndarray( 'generic', toAccessorArray( [ 0.0 ] ), [], [ 0 ], 0, 'row-major' );

assign( [ x, y ] );

t.strictEqual( isSameAccessorArray( x.data, y.data ), true, 'returns expected value' );

t.end();
});
Loading