From 40b07cdb7610f3258f9e2f038e63dd8b584845d4 Mon Sep 17 00:00:00 2001 From: Meet Mangukiya Date: Sat, 14 Oct 2023 21:10:08 +0530 Subject: [PATCH] add test file for solidity, update readme --- README.md | 2 +- test/test.sol | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 test/test.sol diff --git a/README.md b/README.md index 27f0a07a..7ca421f9 100644 --- a/README.md +++ b/README.md @@ -160,7 +160,7 @@ Note: if you need support for Neovim 0.6.x please use the tag `compat/0.6`. - [ ] `scheme` - [ ] `slint` - [ ] `smithy` - - [ ] `solidity` + - [x] `solidity` - [ ] `sparql` - [ ] `sql` - [ ] `starlark` diff --git a/test/test.sol b/test/test.sol new file mode 100644 index 00000000..3ab10397 --- /dev/null +++ b/test/test.sol @@ -0,0 +1,114 @@ +interface SomeInterface { + function someFunction(uint a, uint b) external returns (uint c); + function testFunction(uint) external returns (uint); +} + +contract Contract { + event SomeEvent( + uint a, + uint b, + uint c, + uint d + ); + + error SomeError( + uint a, + uint b, + uint c, + uint d + ); + + struct SomeStruct { + uint a; + uint b; + uint c; + uint d; + } + + enum SomeEnum { + Entry1, + Entry2, + Entry3, + Entry4 + } + + constructor() { + // do some construction + } + + fallback() external payable { + // this is + // fallback + } + + receive() external payable { + // this is + // receive + // function + } + + function someFunction(uint a, uint b) external pure returns (uint _c) { + _c = a + b; + + if (true) { + // do + // something + // in if statement + emit SomeEvent(1, 2, + 3, 4); + } else { + // do + // something + // in else statement + + revert SomeError( + 1, + 2, + 3, 4 + ); + } + + for (uint i = 0; i < 10; i++) { + // something + // in loop + + uint j = 0; + while (j < 5) { + j++; + // something + // something + + try { + // will error + // need to catch + } catch (bytes memory reason) { + // catch + // do some cleanup + } + } + + do { + // this is do + // while + + unchecked { + j++; + } + } while (j < 5); + } + } + + modifier withSomething(uint a) { + // modifier logic + _; + } +} + +library SomeLibrary { + function libraryFunction(uint a, uint b, uint c, uint d) internal pure { + a = 1; + b = 2; + c = 3; + d = 4; + } +}