text: /*
   * This file is part of b6b.
   *
   * Copyright 2017 Dima Krasner
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  #include <stdlib.h>
  #include <assert.h>
  
  #include <b6b.h>
  
  int main()
  {
  	struct b6b_interp interp;
  
  	assert(b6b_interp_new_argv(&interp, 0, NULL, B6B_OPT_TRACE));
  	assert(b6b_call_copy(&interp, "{$export}", 9) == B6B_ERR);
  	b6b_interp_destroy(&interp);
  
  	assert(b6b_interp_new_argv(&interp, 0, NULL, B6B_OPT_TRACE));
  	assert(b6b_call_copy(&interp,
  	                     "{$export a 1337} {$echo 2} {$echo $a}",
  	                     37) == B6B_OK);
  	assert(b6b_as_float(interp.fg->_));
  	assert(interp.fg->_->f == 1337);
  	b6b_interp_destroy(&interp);
  
  	assert(b6b_interp_new_argv(&interp, 0, NULL, B6B_OPT_TRACE));
  	assert(b6b_call_copy(&interp,
  	                     "{$local a 1337} {$call {{$export a 1338}}} {$echo $a}",
  	                     53) == B6B_OK);
  	assert(b6b_as_float(interp.fg->_));
  	assert(interp.fg->_->f == 1338);
  	b6b_interp_destroy(&interp);
  
  	assert(b6b_interp_new_argv(&interp, 0, NULL, B6B_OPT_TRACE));
  	assert(b6b_call_copy(&interp,
  	                     "{$local a 1337} {$call {{$export b}}} {$echo $a}",
  	                     48) == B6B_ERR);
  	b6b_interp_destroy(&interp);
  
  	assert(b6b_interp_new_argv(&interp, 0, NULL, B6B_OPT_TRACE));
  	assert(b6b_call_copy(&interp,
  	                     "{$local a 1337} {$call {{$local a 1338} {$export a}}} {$echo $a}",
  	                     64) == B6B_OK);
  	assert(b6b_as_float(interp.fg->_));
  	assert(interp.fg->_->f == 1338);
  	b6b_interp_destroy(&interp);
  
  	assert(b6b_interp_new_argv(&interp, 0, NULL, B6B_OPT_TRACE));
  	assert(b6b_call_copy(&interp,
  	                     "{$local a 1337} {$call {{$local a 1338} {$export b}}} {$echo $a}",
  	                     64) == B6B_ERR);
  	b6b_interp_destroy(&interp);
  
  	return EXIT_SUCCESS;
  }
  