Ruby Testing 2, 11/9/2004.

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming Lecture 3 Writing Java Applications, Java Development Tools.
Advertisements

Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Introduction to Ruby.
JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Ruby (on Rails) CSE 190M, Spring 2009 Week 2. Arrays Similar to PHP, Ruby arrays… – Are indexed by zero-based integer values – Store an assortment of.
Introducing JavaScript
Programming Languages and Paradigms The C Programming Language.
Coding Standard: General Rules 1.Always be consistent with existing code. 2.Adopt naming conventions consistent with selected framework. 3.Use the same.
The Web Warrior Guide to Web Design Technologies
Introduction to Unix – CS 21 Lecture 11. Lecture Overview Shell Programming Variable Discussion Command line parameters Arithmetic Discussion Control.
Animation Mrs. C. Furman. Animation  We can animate our crab by switching the image between two pictures.  crab.png and crab2.png.
Lecture-5 Though SQL is the natural language of the DBA, it suffers from various inherent disadvantages, when used as a conventional programming language.
Intro to Java Part II. Calling an Objects Methods Use qualified names to call the objects methods. To form – you append the method name to an object reference.
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
Scripting with Ruby What is a scripting language? What is Ruby?
CTEC 1863 – Operating Systems Shell Scripting. CTEC F2 Overview How shell works Command line parameters –Shift command Variables –Including.
Ruby (on Rails) CSE 190M, Spring 2009 Week 1. The Players Kelly "Everyday I'm Hustlin' " Dunn Kim "Mouse" Todd Ryan "Papa T" Tucker.
The Ruby Programming Language
CMSC 330: Organization of Programming Languages 1 Overview of Ruby.
Comp 248 Introduction to Programming Chapter 4 - Defining Classes Part A Dr. Aiman Hanna Department of Computer Science & Software Engineering Concordia.
CSCI 1100/1202 January 16, Why do we need variables? To store intermediate results in a long computation. To store a value that is used more than.
SCRIPTING IN RUBY By Amber Bennett “Ruby is simple in appearance, but is very complex inside, just like our human body.” --Yukihiro Matsumoto.
Python Basic Syntax. Basic Syntax - First Program 1 All python files will have extension.py put the following source code in a test.py file. print "Hello,
CPTR 124 Review for Test 1. Development Tools Editor Similar to a word processor Allows programmer to compose/save/edit source code Compiler/interpreter.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
1 JavaScript in Context. Server-Side Programming.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
Intro and Review Welcome to Java. Introduction Java application programming Use tools from the JDK to compile and run programs. Videos at
Classes CS 21a: Introduction to Computing I First Semester,
Ruby on Rails. What is Ruby? Programming Language Object-oriented Interpreted.
Introduction to Ruby WING Group Meeting 9 Jun 2006 Min-Yen Kan WING Group Meeting 9 Jun 2006 Min-Yen Kan.
What is PHP? PHP stands for PHP: Hypertext Preprocessor PHP is a server-side scripting language, like ASP PHP scripts are executed on the server PHP supports.
Java™ How to Program, 10/e © Copyright by Pearson Education, Inc. All Rights Reserved.
Java development environment and Review of Java. Eclipse TM Intergrated Development Environment (IDE) Running Eclipse: Warning: Never check the “Use this.
CONTENTS Processing structures and commands Control structures – Sequence Sequence – Selection Selection – Iteration Iteration Naming conventions – File.
Introducing Python CS 4320, SPRING Lexical Structure Two aspects of Python syntax may be challenging to Java programmers Indenting ◦Indenting is.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Scripting with Ruby What is a scripting language? What is Ruby?
©Colin Jamison 2004 Shell scripting in Linux Colin Jamison.
Perl Tutorial. Why PERL ??? Practical extraction and report language Similar to shell script but lot easier and more powerful Easy availablity All details.
CSCI 3133 Programming with C Instructor: Bindra Shrestha University of Houston – Clear Lake.
Scripting with Ruby What is a scripting language? What is Ruby?
Introduction to Objective Caml. General comments ML is a purely functional language--there are (almost) no side effects There are two basic dialects of.
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
1 Getting Started with Ruby. 2 What’s Ruby? Ruby is an OO, dynamic, agile language –Everything’s an object For example, try puts -1.abs –Derives strengths.
1 Predefined Classes and Objects Chapter 3. 2 Objectives You will be able to:  Use predefined classes available in the Java System Library in your own.
PHP Reusing Code and Writing Functions 1. Function = a self-contained module of code that: Declares a calling interface – prototype! Performs some task.
© 2006 Pearson Addison-Wesley. All rights reserved 1-1 Chapter 1 Review of Java Fundamentals.
Introduction to information systems RUBY dr inż. Tomasz Pieciukiewicz.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
REEM ALMOTIRI Information Technology Department Majmaah University.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
>> Introduction to JavaScript
Ruby Getting started & Ruby.New Presented by Mario Tayah
Ruby: An Introduction Created by Yukihiro Matsumoto in 1993 (named after his birthstone) Pure OO language (even the number 1 is an instance of a class)
Ruby and other languages….
Intro to PHP & Variables
Chapter 14 Introduction to Ruby.
Basic Ruby Syntax sum = 0 i = 1 while i <= 10 do sum += i*i
Starting JavaProgramming
Chapter 3 Introduction to Classes, Objects Methods and Strings
CIT 383: Administrative Scripting
Copyright © – Curt Hill Bash Flow of Control Copyright © – Curt Hill.
Object Oriented Programming in java
Tutorial 10: Programming with javascript
Chap 2. Identifiers, Keywords, and Types
Code Blocks, Closures, and Continuations
Review of Java Fundamentals
Presentation transcript:

Ruby Testing 2, 11/9/2004

What is Ruby? Scripting language, developed by Yukihiro “Matz” Matsumoto Current version = 1.8

Ruby Documentation Pickaxe book (shown last class) http://www.ruby-doc.org ri command ri <Class name> Ruby Cheat Sheet (on blackboard)

Running Ruby Command line Eclipse SciTE irb ruby –w <file name> More later SciTE Demo irb

Ruby in Eclipse Download Ruby Development Tool from http://rubyeclipse.sourceforge.net Nowhere near the functionality of Java in Eclipse In preferences, set path to ruby bin directory

Ruby Basics Everything is an object Comments start with # and go until end of line Methods are created using def…end

Ruby Naming Initial letter Multi-word names End characters Local variables, method parameters, and method names  lowercase letter or underscore Global variable  $ Instance variable  @ Class variable  @@ Class names, module names, constants  uppercase letter Multi-word names Instance variables  separate words with underscores Class names  use MixedCase End characters ? Indicates method that returns true or false to a query ! Indicates method that modifies the object in place rather than returning a copy

Blocks Allow passing chunks of code in to methods Single line blocks enclosed in {} Multi-line blocks enclosed in do…end Receiving method uses “yield” command to call passed code (can call yield multiple times) Can use parameters [ 1, 3, 4, 7, 9 ].each {|i| puts i }

Strings in Ruby Quotes matter! Strings in “” (double quotes) have replacement processing on them \<char> replacement (like C -- \n = newline, etc) Expression replacement (“Variable x = #{x}” would have the value of x substituted for the #{x}) Strings in ‘’ (single quotes) are treated as literals with no processing Strings in `` (back ticks) are treated as commands to be executed by the operating system

Control structures If…elsif…else…end unless <condition> … end while <condition>… end until <condition>… end case when <condition> then <value>… else… end #.times (e.g. 5.times()) #.upto(#) (e.g. 3.upto(6)) <collection>.each {block}

Ruby equivalents in Java null toString() extends constructor name = class name try…catch import Ruby nil to_s < constructor name = initialize begin…end…rescue require

Test::Unit Very similar to JUnit require ‘test/unit’ Class MyTestClass < Test::Unit::TestCase Use “flunk” instead of JUnit’s “fail”