-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#671] Implement left shift operator by multiplication in C++
* extend language tests
- Loading branch information
Showing
7 changed files
with
187 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule data
updated
2 files
+1 −0 | language/expressions/zs/expressions.zs | |
+52 −0 | language/expressions/zs/expressions/left_shift_operator.zs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
test/extensions/language/expressions/cpp/LeftShiftOperatorTest.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#include "expressions/left_shift_operator/LeftShiftOperator.h" | ||
#include "gtest/gtest.h" | ||
|
||
namespace expressions | ||
{ | ||
namespace left_shift_operator | ||
{ | ||
|
||
TEST(LeftShiftOperatorTest, defaultValues) | ||
{ | ||
LeftShiftOperator leftShiftOperator; | ||
EXPECT_EQ(40, leftShiftOperator.getU32()); | ||
EXPECT_EQ(-40, leftShiftOperator.getI32()); | ||
EXPECT_EQ(32, leftShiftOperator.getU32Complex()); | ||
EXPECT_EQ(-32, leftShiftOperator.getI32Complex()); | ||
EXPECT_EQ(24, leftShiftOperator.getU32Plus()); | ||
EXPECT_EQ(-64, leftShiftOperator.getI32Minus()); | ||
EXPECT_EQ(12, leftShiftOperator.getU32PlusRhsExpr()); | ||
EXPECT_EQ(-24, leftShiftOperator.getI32MinusRhsExpr()); | ||
EXPECT_EQ(11534336, leftShiftOperator.getU63Complex()); | ||
EXPECT_EQ(-9216, leftShiftOperator.getI64Complex()); | ||
} | ||
|
||
TEST(LeftShiftOperatorTest, getU63LShift3) | ||
{ | ||
LeftShiftOperator leftShiftOperator; | ||
ASSERT_EQ(104, leftShiftOperator.funcGetU63LShift3()); | ||
} | ||
|
||
TEST(LeftShiftOperatorTest, getI64LShift4) | ||
{ | ||
LeftShiftOperator leftShiftOperator; | ||
ASSERT_EQ(-208, leftShiftOperator.funcGetI64LShift4()); | ||
} | ||
|
||
TEST(LeftShiftOperatorTest, getU63LShift) | ||
{ | ||
LeftShiftOperator leftShiftOperator; | ||
ASSERT_EQ(13312, leftShiftOperator.funcGetU63LShift()); | ||
} | ||
|
||
TEST(LeftShiftOperatorTest, getI64LShift) | ||
{ | ||
LeftShiftOperator leftShiftOperator; | ||
ASSERT_EQ(-13312, leftShiftOperator.funcGetI64LShift()); | ||
} | ||
|
||
TEST(LeftShiftOperatorTest, getPositiveI32LShift) | ||
{ | ||
LeftShiftOperator leftShiftOperator; | ||
ASSERT_EQ(13312, leftShiftOperator.funcGetPositiveI32LShift()); | ||
} | ||
|
||
TEST(LeftShiftOperatorTest, getI64ComplexLShift) | ||
{ | ||
LeftShiftOperator leftShiftOperator; | ||
ASSERT_EQ(-3072, leftShiftOperator.funcGetI64ComplexLShift()); | ||
} | ||
|
||
} // namespace left_shift_operator | ||
} // namespace expressions |
68 changes: 68 additions & 0 deletions
68
test/extensions/language/expressions/java/expressions/LeftShiftOperatorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package expressions; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import expressions.left_shift_operator.LeftShiftOperator; | ||
|
||
public class LeftShiftOperatorTest | ||
{ | ||
@Test | ||
public void defaultValues() | ||
{ | ||
final LeftShiftOperator leftShiftOperator = new LeftShiftOperator(); | ||
assertEquals(40, leftShiftOperator.getU32()); | ||
assertEquals(-40, leftShiftOperator.getI32()); | ||
assertEquals(32, leftShiftOperator.getU32Complex()); | ||
assertEquals(-32, leftShiftOperator.getI32Complex()); | ||
assertEquals(24, leftShiftOperator.getU32Plus()); | ||
assertEquals(-64, leftShiftOperator.getI32Minus()); | ||
assertEquals(12, leftShiftOperator.getU32PlusRhsExpr()); | ||
assertEquals(-24, leftShiftOperator.getI32MinusRhsExpr()); | ||
assertEquals(11534336, leftShiftOperator.getU63Complex()); | ||
assertEquals(-9216, leftShiftOperator.getI64Complex()); | ||
} | ||
|
||
@Test | ||
public void getU63LShift3() | ||
{ | ||
final LeftShiftOperator leftShiftOperator = new LeftShiftOperator(); | ||
assertEquals(104, leftShiftOperator.funcGetU63LShift3()); | ||
} | ||
|
||
@Test | ||
public void getI64LShift4() | ||
{ | ||
final LeftShiftOperator leftShiftOperator = new LeftShiftOperator(); | ||
assertEquals(-208, leftShiftOperator.funcGetI64LShift4()); | ||
} | ||
|
||
@Test | ||
public void getU63LShift() | ||
{ | ||
final LeftShiftOperator leftShiftOperator = new LeftShiftOperator(); | ||
assertEquals(13312, leftShiftOperator.funcGetU63LShift()); | ||
} | ||
|
||
@Test | ||
public void getI64LShift() | ||
{ | ||
final LeftShiftOperator leftShiftOperator = new LeftShiftOperator(); | ||
assertEquals(-13312, leftShiftOperator.funcGetI64LShift()); | ||
} | ||
|
||
@Test | ||
public void getPositiveI32LShift() | ||
{ | ||
final LeftShiftOperator leftShiftOperator = new LeftShiftOperator(); | ||
assertEquals(13312, leftShiftOperator.funcGetPositiveI32LShift()); | ||
} | ||
|
||
@Test | ||
public void getI64ComplexLShift() | ||
{ | ||
final LeftShiftOperator leftShiftOperator = new LeftShiftOperator(); | ||
assertEquals(-3072, leftShiftOperator.funcGetI64ComplexLShift()); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
test/extensions/language/expressions/python/LeftShiftOperatorTest.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import Expressions | ||
|
||
|
||
class LeftShiftOperatorTest(Expressions.TestCase): | ||
def testDefaultValues(self): | ||
leftShiftOperator = self.api.LeftShiftOperator() | ||
self.assertEqual(40, leftShiftOperator.u32) | ||
self.assertEqual(-40, leftShiftOperator.i32) | ||
self.assertEqual(32, leftShiftOperator.u32_complex) | ||
self.assertEqual(-32, leftShiftOperator.i32_complex) | ||
self.assertEqual(24, leftShiftOperator.u32_plus) | ||
self.assertEqual(-64, leftShiftOperator.i32_minus) | ||
self.assertEqual(12, leftShiftOperator.u32_plus_rhs_expr) | ||
self.assertEqual(-24, leftShiftOperator.i32_minus_rhs_expr) | ||
self.assertEqual(11534336, leftShiftOperator.u63_complex) | ||
self.assertEqual(-9216, leftShiftOperator.i64_complex) | ||
|
||
def testGetU63LShift3(self): | ||
leftShiftOperator = self.api.LeftShiftOperator() | ||
self.assertEqual(104, leftShiftOperator.get_u63l_shift3()) | ||
|
||
def testGetI64LShift4(self): | ||
leftShiftOperator = self.api.LeftShiftOperator() | ||
self.assertEqual(-208, leftShiftOperator.get_i64l_shift4()) | ||
|
||
def testGetU63LShift(self): | ||
leftShiftOperator = self.api.LeftShiftOperator() | ||
self.assertEqual(13312, leftShiftOperator.get_u63l_shift()) | ||
|
||
def testGetI64LShift(self): | ||
leftShiftOperator = self.api.LeftShiftOperator() | ||
self.assertEqual(-13312, leftShiftOperator.get_i64l_shift()) | ||
|
||
def testGetPositiveI32LShift(self): | ||
leftShiftOperator = self.api.LeftShiftOperator() | ||
self.assertEqual(13312, leftShiftOperator.get_positive_i32l_shift()) | ||
|
||
def testGetI64ComplexLShift(self): | ||
leftShiftOperator = self.api.LeftShiftOperator() | ||
self.assertEqual(-3072, leftShiftOperator.get_i64_complex_l_shift()) |