how can i tell the difference between phototransistors, photodiodes, and ir leds?

i have a bunch of ir leds, phototransistors, photodiodes and things i desoldered that are probably light sensors of some kind. is there an easy way to test what they are without destroying them?

For this trick I am going to assume that you also have a 5 volt DC supply, a  10 kilo-ohm (10 KΩ) resistor, and a voltmeter, and a flashlight.  If you have digital camera with a viewfinder, that can be helpful too, but is not totally necessary for all the tricks I'm about to describe.

Suppose that you connect your mystery-two terminal device (be it LED, or phototransistor, or whatev) in series with the 10K resistor and the 5 VDC supply.  Here I assume one side of the 10K resistor is attached to +5 V. The other side of the resistor is connected to your mystery-device.  The other side of the mystery device is attached to ground, 0 V, aka the negative side of the 5V supply.

What is the maximum amount of current that could possibly flow through your mystery component?

To answer that question you assume, in the worst case, that the component is a dead short, with 0 V across it, so that the current that flows is just 5 V, divided by the 10 K resistor, or: Imax = 5V/10K = 5/10000 A = 0.5 mA

The point here is there is an upper limit to the current.  0.5 mA is very small amount of electric current.  This amount of current probably won't  kill the average LED or photodiode.  At the same time this is an amount of current large enough to cause a measurable voltage response in the device. 

Connect the voltmeter across the mystery device. The negative probe
goes to ground, the positive probe goes to the connection between the device and the 10K resistor.

Now I'll break down what you'll see on the volmeter case-by-case.

An open circuit will have infinite resistance.  For example if no component is attached to your tester.  The current will be zero, the voltage drop across the resistor is zero (since i*R=0), and the voltmeter will say +5.0 volts, or whatever the supply voltage is, it will be exactly that.

A reverse biased LED will also look like an open circuit.  No current. and the voltmeter says +5.0 volts.

A forward biased IR-LED will have a voltage of about 0.6 V across it.  Also it may be emitting light that is detectable by your digital camera's viewfinder.  Although if you don't see anything in the viewfinder, it may be just that you need more current.  Try a 1K resistor instead. The voltage across the forward biased LED should still be about 0.6 V, but the current will be 10 times greater.  5 mA max, compared to 0.5 mA.  Note that for visible colors of LED the forward voltage is different (red 1.8V, yellow 2.?V, green 2.?V, blue, 3.6V), and of course these LEDs emit light human eyes can see.

A NPN-phototransistor connected correctly into this circuit, with its emitter connected to ground will have a voltage that varies depending on how much light is hitting it.  That is to say the voltage will be closer to 5 V when totally dark, and closer to 0 when illuminated.  That's what the flashlight is for, for testing this response.

A NPN-phototransistor connected upside down, will, I think, look like an open circuit.  Again, this looks like 5 V on the voltmeter.

In any of those cases where the voltmeter says 5V, that is open-circuit, just pull out the mystery-component, and try plugging it in with the reverse polarity that you tried before, and see if the voltmeter says anything.