Skip to content

Commit

Permalink
Adding tests for scoping
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Stefanov <[email protected]>
  • Loading branch information
stefan-stefanooov committed Oct 19, 2023
1 parent 50fa929 commit 9635dc5
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 0 deletions.
25 changes: 25 additions & 0 deletions contracts/solidity/scoping/Scoping.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.20;

contract Scoping {
function minimalScoping() pure public {
{
uint same;
same = 1;
}

{
uint same;
same = 3;
}
}

function reassign() pure public returns (uint) {
uint x = 1;
{
x = 2; // this will assign to the outer variable
uint x;
}
return x; // x has value 2
}
}
2 changes: 2 additions & 0 deletions test/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ const Contract = {
Functions: 'Functions',
FunctionsChild: 'FunctionsChild',
FunctionsParent: 'FunctionsParent',
Defaults: 'Defaults',
Scoping: 'Scoping',
}

const CALL_EXCEPTION = 'CALL_EXCEPTION'
Expand Down
52 changes: 52 additions & 0 deletions test/solidity/defaults/defaults.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const { expect, assert } = require('chai')
const { ethers } = require('hardhat')
const Constants = require('../../constants')

describe('Solidity Errors', function () {
let signers
let contract

before(async function () {
signers = await ethers.getSigners()

const factory = await ethers.getContractFactory(Constants.Contract.Errors)
contract = await factory.deploy()
})

it('should confirm solidity functionality: "uint<M>" cover different variations', async function () {
throw new Error('Not implemented')
})

it('should confirm solidity functionality: "int<M>" cover different variations', async function () {
throw new Error('Not implemented')
})

it('should confirm solidity functionality: "fixed<M>x<N>" cover different variations', async function () {
throw new Error('Not implemented')
})

it('should confirm solidity functionality: "unfixed<M>x<N>" cover different variations', async function () {
throw new Error('Not implemented')
})

it('should confirm solidity functionality: "bytes<M>"', async function () {
throw new Error('Not implemented')
})

it('should confirm solidity functionality: string', async function () {
throw new Error('Not implemented')
})

it('should confirm solidity functionality: "<type>[]"', async function () {
throw new Error('Not implemented')
})

it('should confirm solidity functionality: "address"', async function () {
throw new Error('Not implemented')
})

it('should confirm solidity functionality: "mapping"', async function () {
throw new Error('Not implemented')
})

})
39 changes: 39 additions & 0 deletions test/solidity/scoping/scoping.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*-
*
* Hedera JSON RPC Relay - Hardhat Example
*
* Copyright (C) 2023 Hedera Hashgraph, LLC
*
* 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.
*
*/

const { expect } = require('chai')
const { ethers } = require('hardhat')
const Constants = require('../../constants')

describe('Scoping tests', () => {
let contract

before(async () => {
const factory = await ethers.getContractFactory(Constants.Contract.Scoping)
contract = await factory.deploy()
})

it('should verify the solidity functionality: "scoping"', async () => {
await contract.minimalScoping();
const resReassign = await contract.reassign();

expect(resReassign).to.equal(2);
})
})

0 comments on commit 9635dc5

Please sign in to comment.