|
7 | 7 | #include <scratchcpp/thread.h> |
8 | 8 | #include <scratchcpp/executablecode.h> |
9 | 9 | #include <scratchcpp/executioncontext.h> |
| 10 | +#include <scratchcpp/list.h> |
10 | 11 | #include <enginemock.h> |
11 | 12 | #include <randomgeneratormock.h> |
12 | 13 | #include <stacktimermock.h> |
@@ -1902,3 +1903,41 @@ TEST_F(MotionBlocksTest, SetRotationStyle) |
1902 | 1903 | builder.run(); |
1903 | 1904 | } |
1904 | 1905 | } |
| 1906 | + |
| 1907 | +TEST_F(MotionBlocksTest, XPosition) |
| 1908 | +{ |
| 1909 | + { |
| 1910 | + auto sprite = std::make_shared<Sprite>(); |
| 1911 | + ScriptBuilder builder(m_extension.get(), m_engine, sprite); |
| 1912 | + |
| 1913 | + builder.addBlock("motion_xposition"); |
| 1914 | + builder.captureBlockReturnValue(); |
| 1915 | + builder.build(); |
| 1916 | + |
| 1917 | + sprite->setX(5.2); |
| 1918 | + sprite->setY(-0.25); |
| 1919 | + sprite->setDirection(-61.42); |
| 1920 | + builder.run(); |
| 1921 | + |
| 1922 | + List *list = builder.capturedValues(); |
| 1923 | + ASSERT_EQ(list->size(), 1); |
| 1924 | + ASSERT_EQ(Value(list->data()[0]).toDouble(), 5.2); |
| 1925 | + } |
| 1926 | + |
| 1927 | + m_engine->clear(); |
| 1928 | + |
| 1929 | + { |
| 1930 | + auto stage = std::make_shared<Stage>(); |
| 1931 | + ScriptBuilder builder(m_extension.get(), m_engine, stage); |
| 1932 | + |
| 1933 | + builder.addBlock("motion_xposition"); |
| 1934 | + builder.captureBlockReturnValue(); |
| 1935 | + |
| 1936 | + builder.build(); |
| 1937 | + builder.run(); |
| 1938 | + |
| 1939 | + List *list = builder.capturedValues(); |
| 1940 | + ASSERT_EQ(list->size(), 1); |
| 1941 | + ASSERT_EQ(Value(list->data()[0]).toDouble(), 0); |
| 1942 | + } |
| 1943 | +} |
0 commit comments