Exemple #1
0
        public void codeGenTest_Method_StackCount()
        {
            BFTestHelper.debugMethod_Output("0 2 6 0 ", "a()",
                                            @"
				void a()
				var 
					stack<int>[8] stck;
				begin
					out stck.count();

					stck.push(0);
					stck.push(0);

					out stck.count();

					stck.push(0);
					stck.push(0);
					stck.push(0);
					stck.push(0);

					out stck.count();

					while (!stck.empty()) do stck.pop(); end

					out stck.count();
				end
			"            );
        }
Exemple #2
0
        public void codeGenTest_Method_PreDecrement()
        {
            BFTestHelper.debugMethod_Output("4 ", "a()",
                                            @"
				void a()
				var
					int i;
				begin
					i = 5;

					OUT --i;
				end
			"            );
        }
Exemple #3
0
        public void codeGenTest_Method_PostIncrement()
        {
            BFTestHelper.debugMethod_Output("5 ", "a()",
                                            @"
				void a()
				var
					int i;
				begin
					i = 5;

					OUT i++;
				end
			"            );
        }
Exemple #4
0
        public void codeGenTest_Method_For()
        {
            BFTestHelper.debugMethod_Output("ABCDEFGHIJKLMNOPQRSTUVWXYZ", "a()",
                                            @"
				void a()
				var
					int i;
				begin
					FOR(i = (int)'A'; i <= (int)'Z'; i++) DO
						OUT (char)i;
					END
				end
			"            );
        }
Exemple #5
0
        public void codeGenTest_Method_UniformArr()
        {
            BFTestHelper.debugMethod_Output("6 6 6 6 6 6 6 6 6 6 6 6 ", "a()",
                                            @"
				void a()
				var 
					int[12] arr := {6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6};
					int i;
				begin
	                for (i=0; i < 12; i++) do
						out arr[i];
	                end
				end
			"            );
        }
Exemple #6
0
        public void codeGenTest_Method_StackFill()
        {
            BFTestHelper.debugMethod_Output("128 64 32 16 8 4 2 1 ", "a()",
                                            @"
				void a()
				var 
					stack<int>[8] stck;
					int i := 1;
				begin
					while(!stck.Full()) do
						stck.push(i);
						i *= 2;
					end

					while (!stck.empty()) do
						out stck.pop();
					end
				end
			"            );
        }
Exemple #7
0
        public void codeGenTest_Method_SetDisplay()
        {
            BFTestHelper.debugMethod_Output("1 ", "a()",
                                            @"
				void a()
				begin
					display[0, 0] = '0';
					OUT (int)(display[0, 0] == '0');
				end
			"            );

            BFTestHelper.debugMethod_Output("1", "a()",
                                            @"
				void a()
				begin
					display[0, 0] = '0';
					OUT (digit)(display[0, 0] == '0');
				end
			"            );
        }
Exemple #8
0
        public void codeGenTest_Method_StackInit()
        {
            BFTestHelper.debugMethod_Output("119922335588", "a()",
                                            @"
				void a()
				var 
					stack<digit>[6] x;
				begin
					x.Push(#8);
					x.Push(#5);
					x.Push(#3);
					x.Push(#2);
					x.Push(#9);
					x.Push(#1);

					while (!x.empty()) do
						out x.peek();
						out x.pop();
					end
				end
			"            );
        }
Exemple #9
0
        public void codeGenTest_Method_StackReverse()
        {
            BFTestHelper.debugMethod_Output("dlroW olleH", "a()",
                                            @"
				void a()
				var 
					char[11] str := ''Hello World'';
					stack<char>[16] stck;
					int i;
				begin

					for (i=0; i < 11; i++) do
						stck.Push(str[i]);
					end

					i=0;
					while(!stck.Empty()) do
						str[i++] = stck.pop();
					end

					out str;
				end
			"            );
        }
Exemple #10
0
        public void codeGenTest_Method_Goto()
        {
            BFTestHelper.debugMethod_Output("abc", "a()",
                                            @"
				void a()
				begin
					goto lbl_S;	
				lbl0:
					return;
				lbl_S:
					out ''a'';
					goto lbl1;
					out ''x'';
				lbl1:
					out ''b'';
					goto lbl2;
				lbl2:
					out ''c'';
					goto lbl0;
					out ''x'';
					return;
				end
			"            );
        }