view test.sh @ 0:7d266b61ec2a

initial commit return valueなコンパイラを作成
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Wed, 24 Jul 2019 13:58:02 +0900
parents
children 59c56be5222e
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

echo OK