view test.sh @ 2:75f25ab4022c

update
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Thu, 25 Jul 2019 09:00:25 +0900
parents 59c56be5222e
children
line wrap: on
line source

#!/bin/bash
try() {
  expected="$1"
  input="$2"

  ./9cc "$input" > tmp.s
  gcc -o tmp tmp.s
  ./tmp
  actual="$?"

  if [ "$actual" = "$expected" ]; then
    echo "$input => $actual"
  else
    echo "$input => $expected expected, but got $actual"
    exit 1
  fi
}

try 0 0
try 42 42
try 21 "5+20-4"
try 41 " 12 + 34 - 5 "

echo OK