public void 反復() { Assert.AreEqual(ListCell.Null, Execute <ListCell>("1を0だけ反復する。")); Assert.AreEqual(ListCell.Of(1), Execute <ListCell>("1を1だけ反復する。")); Assert.AreEqual(ListCell.Of(1, 1), Execute <ListCell>("1を2だけ反復する。")); Assert.AreEqual(ListCell.Of(1, 1, 1), Execute <ListCell>("1を3だけ反復する。")); }
public void 文字分割() { Assert.AreEqual(ListCell.Null, Execute <ListCell>("無を文字分割する。")); Assert.AreEqual(ListCell.Null, Execute <ListCell>("「」を文字分割する。")); Assert.AreEqual( ListCell.Of("あ"), Execute <ListCell>("「あ」を文字分割する。")); Assert.AreEqual( ListCell.Of("あ", "い", "う", "え", "お"), Execute <ListCell>("「あいうえお」を文字分割する。")); }
public void 分岐文の中で同じ名前の変数を使っても問題が発生しない() { // 副作用を有り。 var engine = new Engine(); var code = "4を値とする。" + "以下の定義で条件でテストする。" + " もし条件なら,3を値とする。" + " 他なら,5を値とする。" + " 値である。" + "以上。" + "真でテストし,結果Aとする。" + "偽でテストし,結果Bとする。" + "[値,結果A,結果B]である。"; Assert.AreEqual(ListCell.Of(4, 3, 5), (ListCell)engine.Execute(code, Statics.TestName)); }
public void 平坦化() { Assert.AreEqual( ListCell.Null, Execute <ListCell>("無を平坦化する。")); Assert.AreEqual( ListCell.Of(3), Execute <ListCell>("3を平坦化する。")); Assert.AreEqual( ListCell.Of(3, 5, 7), Execute <ListCell>("3と5と7を平坦化する。")); Assert.AreEqual( ListCell.Of(1, 2, 3), Execute <ListCell>("[1,2,3]を平坦化する。")); Assert.AreEqual( ListCell.Of(0, 1, 2, 3, 4, 5, 6), Execute <ListCell>("[0,[],[1],[2,3],[4,[],[5,[6]]]]を平坦化する。")); Assert.AreEqual( ListCell.Of(1, 2, 3, 4, 5, 6, 7, 8, 9), Execute <ListCell>("(((1:2):(3:4:5)):(6:(7:8):9))を平坦化する。")); }
public void それぞれ_によるMap処理() { // リストに対して var actual1 = Execute <ListCell>("【○×○】を二乗とする。[1,2,3,4,5]をそれぞれ二乗する。"); var expected1 = ListCell.Of(1, 4, 9, 16, 25); Assert.AreEqual(expected1, actual1); var actual2 = Execute <Tuple <object, object> >("【○×2】を二倍とする。3と4をそれぞれ二倍する。"); var expected2 = new Tuple <object, object>(6, 8); Assert.AreEqual(expected2, actual2); var actual3 = Execute <ListCell>("[1,2,3]をそれぞれ【□+1】する。"); var expected3 = ListCell.Of(2, 3, 4); Assert.AreEqual(expected3, actual3); var actual4 = Execute <ListCell>("[1:2,3:4,5:6,7:8]をそれぞれ【○+△】する。"); var expected4 = ListCell.Of(3, 7, 11, 15); Assert.AreEqual(expected4, actual4); }